If necessary, expand the bytebuffer_t internal buffer to accomodate the specified additional size.
Definition at line 140 of file bytebuffer.c.
142 LWDEBUGF(2,
"Entered bytebuffer_makeroom with space need of %d", size_to_add);
143 size_t current_write_size = (
s->writecursor -
s->buf_start);
144 size_t capacity =
s->capacity;
145 size_t required_size = current_write_size + size_to_add;
147 LWDEBUGF(2,
"capacity = %d and required size = %d",capacity ,required_size);
148 while (capacity < required_size)
151 if ( capacity >
s->capacity )
153 size_t current_read_size = (
s->readcursor -
s->buf_start);
154 LWDEBUGF(4,
"We need to realloc more memory. New capacity is %d", capacity);
155 if (
s->buf_start ==
s->buf_static )
158 memcpy(
s->buf_start,
s->buf_static,
s->capacity);
164 s->capacity = capacity;
165 s->writecursor =
s->buf_start + current_write_size;
166 s->readcursor =
s->buf_start + current_read_size;
void * lwrealloc(void *mem, size_t size)
void * lwalloc(size_t size)
#define LWDEBUGF(level, msg,...)
References lwalloc(), LWDEBUGF, lwrealloc(), and s.
Referenced by bytebuffer_append_bulk(), bytebuffer_append_byte(), bytebuffer_append_bytebuffer(), bytebuffer_append_double(), bytebuffer_append_int(), bytebuffer_append_uvarint(), and bytebuffer_append_varint().