PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ hexbytes_from_bytes()

char* hexbytes_from_bytes ( uint8_t bytes,
size_t  size 
)

Definition at line 39 of file lwout_wkb.c.

References hexchr, lwalloc(), and lwerror().

Referenced by cu_twkb(), cu_twkb_idlist(), cu_twkb_in(), cu_wkb_in(), do_test_s32_varint(), do_test_s64_varint(), do_test_u32_varint(), and do_test_u64_varint().

40 {
41  char *hex;
42  int i;
43  if ( ! bytes || ! size )
44  {
45  lwerror("hexbutes_from_bytes: invalid input");
46  return NULL;
47  }
48  hex = lwalloc(size * 2 + 1);
49  hex[2*size] = '\0';
50  for( i = 0; i < size; i++ )
51  {
52  /* Top four bits to 0-F */
53  hex[2*i] = hexchr[bytes[i] >> 4];
54  /* Bottom four bits to 0-F */
55  hex[2*i+1] = hexchr[bytes[i] & 0x0F];
56  }
57  return hex;
58 }
static char * hexchr
Definition: lwout_wkb.c:37
void * lwalloc(size_t size)
Definition: lwutil.c:229
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Here is the call graph for this function:
Here is the caller graph for this function: