PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ bytebuffer_append_double()

void bytebuffer_append_double ( bytebuffer_t buf,
const double  val,
int  swap 
)

Writes a float64 to the buffer.

Definition at line 307 of file bytebuffer.c.

308 {
309  LWDEBUGF(2,"Entered bytebuffer_append_double with value %lf swap = %d", val, swap);
310 
311  LWDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
312  char *dptr = (char*)(&val);
313  int i = 0;
314 
315  if ( sizeof(double) != WKB_DOUBLE_SIZE )
316  {
317  lwerror("Machine double size is not %d bytes!", WKB_DOUBLE_SIZE);
318  }
319 
321 
322  /* Machine/request arch mismatch, so flip byte order */
323  if ( swap )
324  {
325  LWDEBUG(4,"Ok, let's do the swapping thing");
326  for ( i = 0; i < WKB_DOUBLE_SIZE; i++ )
327  {
328  *(buf->writecursor) = dptr[WKB_DOUBLE_SIZE - 1 - i];
329  buf->writecursor += 1;
330  }
331  }
332  /* If machine arch and requested arch match, don't flip byte order */
333  else
334  {
335  LWDEBUG(4,"Ok, let's do the memcopying thing");
336  memcpy(buf->writecursor, dptr, WKB_DOUBLE_SIZE);
338  }
339 
340  LWDEBUG(4,"Return from bytebuffer_append_double");
341  return;
342 
343 }
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:140
#define WKB_DOUBLE_SIZE
Well-Known Binary (WKB) Output Variant Types.
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
uint8_t * writecursor
Definition: bytebuffer.h:42
uint8_t * buf_start
Definition: bytebuffer.h:41

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

Here is the call graph for this function: