PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ bytebuffer_merge()

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 388 of file bytebuffer.c.

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

389 {
390  size_t total_size = 0, current_size, acc_size = 0;
391  int i;
392  for ( i = 0; i < nbuffers; i++ )
393  {
394  total_size += bytebuffer_getlength(buff_array[i]);
395  }
396 
398  for ( i = 0; i < nbuffers; i++)
399  {
400  current_size = bytebuffer_getlength(buff_array[i]);
401  memcpy(res->buf_start+acc_size, buff_array[i]->buf_start, current_size);
402  acc_size += current_size;
403  }
404  res->writecursor = res->buf_start + total_size;
405  res->readcursor = res->buf_start;
406  return res;
407 }
uint8_t * writecursor
Definition: bytebuffer.h:42
tuple res
Definition: window.py:78
uint8_t * readcursor
Definition: bytebuffer.h:43
bytebuffer_t * bytebuffer_create_with_size(size_t size)
Allocate a new bytebuffer_t.
Definition: bytebuffer.c:44
size_t bytebuffer_getlength(const bytebuffer_t *s)
Returns the length of the current buffer.
Definition: bytebuffer.c:377
uint8_t * buf_start
Definition: bytebuffer.h:41
Here is the call graph for this function: