PostGIS  2.5.7dev-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 bytebuffers and resulting bytebuffer

Definition at line 384 of file bytebuffer.c.

385 {
386  size_t total_size = 0, current_size, acc_size = 0;
387  int i;
388  for ( i = 0; i < nbuffers; i++ )
389  {
390  total_size += bytebuffer_getlength(buff_array[i]);
391  }
392 
394  for ( i = 0; i < nbuffers; i++)
395  {
396  current_size = bytebuffer_getlength(buff_array[i]);
397  memcpy(res->buf_start+acc_size, buff_array[i]->buf_start, current_size);
398  acc_size += current_size;
399  }
400  res->writecursor = res->buf_start + total_size;
401  res->readcursor = res->buf_start;
402  return res;
403 }
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:373
tuple res
Definition: window.py:78

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

Here is the call graph for this function: