PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ bytebuffer_init_with_size()

void bytebuffer_init_with_size ( bytebuffer_t s,
size_t  size 
)

Allocate just the internal buffer of an existing bytebuffer_t struct.

Useful for allocating short-lived bytebuffers off the stack.

Definition at line 71 of file bytebuffer.c.

References bytebuffer_t::buf_start, bytebuffer_t::buf_static, BYTEBUFFER_STATICSIZE, bytebuffer_t::capacity, lwalloc(), bytebuffer_t::readcursor, and bytebuffer_t::writecursor.

Referenced by lwgeom_to_twkb_with_idlist(), lwgeom_write_to_buffer(), and ptarray_to_twkb_buf().

72 {
73  if ( size < BYTEBUFFER_STATICSIZE )
74  {
76  s->buf_start = s->buf_static;
77  }
78  else
79  {
80  s->buf_start = lwalloc(size);
81  s->capacity = size;
82  }
83  s->readcursor = s->writecursor = s->buf_start;
84  memset(s->buf_start, 0, s->capacity);
85 }
uint8_t buf_static[BYTEBUFFER_STATICSIZE]
Definition: bytebuffer.h:44
uint8_t * writecursor
Definition: bytebuffer.h:42
#define BYTEBUFFER_STATICSIZE
Definition: bytebuffer.h:36
uint8_t * readcursor
Definition: bytebuffer.h:43
size_t capacity
Definition: bytebuffer.h:40
uint8_t * buf_start
Definition: bytebuffer.h:41
void * lwalloc(size_t size)
Definition: lwutil.c:229
Here is the call graph for this function:
Here is the caller graph for this function: