PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ integer_from_wkb_state()

static uint32_t integer_from_wkb_state ( wkb_parse_state s)
static

Int32 Read 4-byte integer and advance the parse state forward.

Definition at line 267 of file lwin_wkb.c.

References wkb_parse_state::pos, wkb_parse_state::swap_bytes, WKB_INT_SIZE, and wkb_parse_state_check().

Referenced by lwcollection_from_wkb_state(), lwcurvepoly_from_wkb_state(), lwgeom_from_wkb_state(), lwpoly_from_wkb_state(), lwtriangle_from_wkb_state(), and ptarray_from_wkb_state().

268 {
269  uint32_t i = 0;
270 
272 
273  memcpy(&i, s->pos, WKB_INT_SIZE);
274 
275  /* Swap? Copy into a stack-allocated integer. */
276  if( s->swap_bytes )
277  {
278  int j = 0;
279  uint8_t tmp;
280 
281  for( j = 0; j < WKB_INT_SIZE/2; j++ )
282  {
283  tmp = ((uint8_t*)(&i))[j];
284  ((uint8_t*)(&i))[j] = ((uint8_t*)(&i))[WKB_INT_SIZE - j - 1];
285  ((uint8_t*)(&i))[WKB_INT_SIZE - j - 1] = tmp;
286  }
287  }
288 
289  s->pos += WKB_INT_SIZE;
290  return i;
291 }
#define WKB_INT_SIZE
unsigned int uint32_t
Definition: uthash.h:78
static void wkb_parse_state_check(wkb_parse_state *s, size_t next)
Check that we are not about to read off the end of the WKB array.
Definition: lwin_wkb.c:125
unsigned char uint8_t
Definition: uthash.h:79
const uint8_t * pos
Definition: lwin_wkb.c:46
Here is the call graph for this function:
Here is the caller graph for this function: