PostGIS  2.3.7dev-r@@SVN_REVISION@@
bytebuffer_t* bytebuffer_merge ( bytebuffer_t **  buff_array,
int  nbuffers 
)

Returns a new bytebuffer were both ingoing bytebuffers is merged.

Caller is responsible for freeing both incoming bytefyffers and resulting bytebuffer

Definition at line 336 of file bytebuffer.c.

References bytebuffer_t::buf_start, bytebuffer_create_with_size(), bytebuffer_getlength(), bytebuffer_t::readcursor, window::res, and bytebuffer_t::writecursor.

337 {
338  size_t total_size = 0, current_size, acc_size = 0;
339  int i;
340  for ( i = 0; i < nbuffers; i++ )
341  {
342  total_size += bytebuffer_getlength(buff_array[i]);
343  }
344 
346  for ( i = 0; i < nbuffers; i++)
347  {
348  current_size = bytebuffer_getlength(buff_array[i]);
349  memcpy(res->buf_start+acc_size, buff_array[i]->buf_start, current_size);
350  acc_size += current_size;
351  }
352  res->writecursor = res->buf_start + total_size;
353  res->readcursor = res->buf_start;
354  return res;
355 }
uint8_t * writecursor
Definition: bytebuffer.h:41
tuple res
Definition: window.py:78
uint8_t * readcursor
Definition: bytebuffer.h:42
bytebuffer_t * bytebuffer_create_with_size(size_t size)
Allocate a new bytebuffer_t.
Definition: bytebuffer.c:44
uint8_t * buf_start
Definition: bytebuffer.h:40
size_t bytebuffer_getlength(bytebuffer_t *s)
Returns the length of the current buffer.
Definition: bytebuffer.c:325

Here is the call graph for this function: