PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ bytebuffer_create_with_size()

bytebuffer_t* bytebuffer_create_with_size ( size_t  size)

Allocate a new bytebuffer_t.

Use bytebuffer_destroy to free.

Definition at line 44 of file bytebuffer.c.

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

Referenced by bytebuffer_create(), and bytebuffer_merge().

45 {
46  LWDEBUGF(2,"Entered bytebuffer_create_with_size %d", size);
47  bytebuffer_t *s;
48 
49  s = lwalloc(sizeof(bytebuffer_t));
50  if ( size < BYTEBUFFER_STATICSIZE )
51  {
53  s->buf_start = s->buf_static;
54  }
55  else
56  {
57  s->buf_start = lwalloc(size);
58  s->capacity = size;
59  }
60  s->readcursor = s->writecursor = s->buf_start;
61  memset(s->buf_start,0,s->capacity);
62  LWDEBUGF(4,"We create a buffer on %p of %d bytes", s->buf_start, s->capacity);
63  return s;
64 }
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
char * s
Definition: cu_in_wkt.c:23
uint8_t * buf_start
Definition: bytebuffer.h:41
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
Here is the call graph for this function:
Here is the caller graph for this function: