PostGIS  3.0.6dev-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 36 of file bytebuffer.c.

37 {
38  if ( size < BYTEBUFFER_STATICSIZE )
39  {
40  s->capacity = BYTEBUFFER_STATICSIZE;
41  s->buf_start = s->buf_static;
42  }
43  else
44  {
45  s->buf_start = lwalloc(size);
46  s->capacity = size;
47  }
48  s->readcursor = s->writecursor = s->buf_start;
49  memset(s->buf_start, 0, s->capacity);
50 }
#define BYTEBUFFER_STATICSIZE
Definition: bytebuffer.h:36
char * s
Definition: cu_in_wkt.c:23
void * lwalloc(size_t size)
Definition: lwutil.c:227

References BYTEBUFFER_STATICSIZE, lwalloc(), and s.

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

Here is the call graph for this function:
Here is the caller graph for this function: