PostGIS  2.3.7dev-r@@SVN_REVISION@@
static void bytebuffer_makeroom ( bytebuffer_t s,
size_t  size_to_add 
)
inlinestatic

If necessary, expand the bytebuffer_t internal buffer to accomodate the specified additional size.

Definition at line 119 of file bytebuffer.c.

References bytebuffer_t::buf_start, bytebuffer_t::capacity, LWDEBUGF, lwrealloc(), bytebuffer_t::readcursor, and bytebuffer_t::writecursor.

Referenced by bytebuffer_append_bulk(), bytebuffer_append_byte(), bytebuffer_append_bytebuffer(), bytebuffer_append_double(), bytebuffer_append_int(), bytebuffer_append_uvarint(), and bytebuffer_append_varint().

120 {
121  LWDEBUGF(2,"Entered bytebuffer_makeroom with space need of %d", size_to_add);
122  size_t current_write_size = (s->writecursor - s->buf_start);
123  size_t capacity = s->capacity;
124  size_t required_size = current_write_size + size_to_add;
125 
126  LWDEBUGF(2,"capacity = %d and required size = %d",capacity ,required_size);
127  while (capacity < required_size)
128  capacity *= 2;
129 
130  if ( capacity > s->capacity )
131  {
132  LWDEBUGF(4,"We need to realloc more memory. New capacity is %d", capacity);
133  s->buf_start = lwrealloc(s->buf_start, capacity);
134  s->capacity = capacity;
135  s->writecursor = s->buf_start + current_write_size;
136  s->readcursor = s->buf_start + (s->readcursor - s->buf_start);
137  }
138  return;
139 }
uint8_t * writecursor
Definition: bytebuffer.h:41
uint8_t * readcursor
Definition: bytebuffer.h:42
size_t capacity
Definition: bytebuffer.h:39
void * lwrealloc(void *mem, size_t size)
Definition: lwutil.c:235
uint8_t * buf_start
Definition: bytebuffer.h:40
#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: