PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ bytebuffer_append_int()

void bytebuffer_append_int ( bytebuffer_t buf,
const int  val,
int  swap 
)

Definition at line 226 of file bytebuffer.c.

References bytebuffer_t::buf_start, bytebuffer_makeroom(), LWDEBUG, LWDEBUGF, lwerror(), WKB_INT_SIZE, and bytebuffer_t::writecursor.

227 {
228  LWDEBUGF(2,"Entered bytebuffer_append_int with value %d, swap = %d", val, swap);
229 
230  LWDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
231  char *iptr = (char*)(&val);
232  int i = 0;
233 
234  if ( sizeof(int) != WKB_INT_SIZE )
235  {
236  lwerror("Machine int size is not %d bytes!", WKB_INT_SIZE);
237  }
238 
240  /* Machine/request arch mismatch, so flip byte order */
241  if ( swap)
242  {
243  LWDEBUG(4,"Ok, let's do the swaping thing");
244  for ( i = 0; i < WKB_INT_SIZE; i++ )
245  {
246  *(buf->writecursor) = iptr[WKB_INT_SIZE - 1 - i];
247  buf->writecursor += 1;
248  }
249  }
250  /* If machine arch and requested arch match, don't flip byte order */
251  else
252  {
253  LWDEBUG(4,"Ok, let's do the memcopying thing");
254  memcpy(buf->writecursor, iptr, WKB_INT_SIZE);
255  buf->writecursor += WKB_INT_SIZE;
256  }
257 
258  LWDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
259  return;
260 
261 }
#define WKB_INT_SIZE
uint8_t * writecursor
Definition: bytebuffer.h:53
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
uint8_t * buf_start
Definition: bytebuffer.h:52
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
static void bytebuffer_makeroom(bytebuffer_t *s, size_t size_to_add)
If necessary, expand the bytebuffer_t internal buffer to accomodate the specified additional size...
Definition: bytebuffer.c:131
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: