PostGIS  2.2.8dev-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 348 of file bytebuffer.c.

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

349 {
350  size_t total_size = 0, current_size, acc_size = 0;
351  int i;
352  for ( i = 0; i < nbuffers; i++ )
353  {
354  total_size += bytebuffer_getlength(buff_array[i]);
355  }
356 
358  for ( i = 0; i < nbuffers; i++)
359  {
360  current_size = bytebuffer_getlength(buff_array[i]);
361  memcpy(res->buf_start+acc_size, buff_array[i]->buf_start, current_size);
362  acc_size += current_size;
363  }
364  res->writecursor = res->buf_start + total_size;
365  res->readcursor = res->buf_start;
366  return res;
367 }
uint8_t * writecursor
Definition: bytebuffer.h:53
tuple res
Definition: window.py:78
uint8_t * readcursor
Definition: bytebuffer.h:54
bytebuffer_t * bytebuffer_create_with_size(size_t size)
Allocate a new bytebuffer_t.
Definition: bytebuffer.c:56
uint8_t * buf_start
Definition: bytebuffer.h:52
size_t bytebuffer_getlength(bytebuffer_t *s)
Returns the length of the current buffer.
Definition: bytebuffer.c:337
Here is the call graph for this function: