PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ hexbytes_from_bytes()

char* hexbytes_from_bytes ( uint8_t *  bytes,
size_t  size 
)

Definition at line 25 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().

26 {
27  char *hex;
28  int i;
29  if ( ! bytes || ! size )
30  {
31  lwerror("hexbutes_from_bytes: invalid input");
32  return NULL;
33  }
34  hex = lwalloc(size * 2 + 1);
35  hex[2*size] = '\0';
36  for( i = 0; i < size; i++ )
37  {
38  /* Top four bits to 0-F */
39  hex[2*i] = hexchr[bytes[i] >> 4];
40  /* Bottom four bits to 0-F */
41  hex[2*i+1] = hexchr[bytes[i] & 0x0F];
42  }
43  return hex;
44 }
static char * hexchr
Definition: lwout_wkb.c:23
void * lwalloc(size_t size)
Definition: lwutil.c:199
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
Here is the call graph for this function:
Here is the caller graph for this function: