36 LWDEBUG(2,
"Entered bytebuffer_create");
46 LWDEBUGF(2,
"Entered bytebuffer_create_with_size %d", size);
142 LWDEBUGF(2,
"Entered bytebuffer_makeroom with space need of %d", size_to_add);
146 size_t required_size = current_write_size + size_to_add;
148 LWDEBUGF(2,
"capacity = %d and required size = %d",capacity ,required_size);
149 while (capacity < required_size)
154 LWDEBUGF(4,
"We need to realloc more memory. New capacity is %d", capacity);
179 *buffer_length = bufsz;
199 LWDEBUGF(2,
"Entered bytebuffer_append_byte with value %d", val);
213 LWDEBUGF(2,
"bytebuffer_append_bulk with size %d",size);
226 LWDEBUG(2,
"bytebuffer_append_bytebuffer");
268 LWDEBUGF(2,
"Entered bytebuffer_append_int with value %d, swap = %d", val, swap);
271 char *iptr = (
char*)(&val);
283 LWDEBUG(4,
"Ok, let's do the swaping thing");
293 LWDEBUG(4,
"Ok, let's do the memcopying thing");
313 LWDEBUGF(2,
"Entered bytebuffer_append_double with value %lf swap = %d", val, swap);
316 char *dptr = (
char*)(&val);
329 LWDEBUG(4,
"Ok, let's do the swapping thing");
332 *(buf->
writecursor) = dptr[WKB_DOUBLE_SIZE - 1 - i];
339 LWDEBUG(4,
"Ok, let's do the memcopying thing");
344 LWDEBUG(4,
"Return from bytebuffer_append_double");
390 size_t total_size = 0, current_size, acc_size = 0;
392 for ( i = 0; i < nbuffers; i++ )
398 for ( i = 0; i < nbuffers; i++)
402 acc_size += current_size;
uint8_t buf_static[BYTEBUFFER_STATICSIZE]
int64_t bytebuffer_read_varint(bytebuffer_t *b)
Reads a signed varInt from the buffer.
void bytebuffer_append_bytebuffer(bytebuffer_t *write_to, bytebuffer_t *write_from)
Writes a uint8_t value to the buffer.
bytebuffer_t * bytebuffer_create(void)
Allocate a new bytebuffer_t.
#define BYTEBUFFER_STATICSIZE
void bytebuffer_append_byte(bytebuffer_t *s, const uint8_t val)
Writes a uint8_t value to the buffer.
#define WKB_DOUBLE_SIZE
Well-Known Binary (WKB) Output Variant Types.
#define LWDEBUG(level, msg)
bytebuffer_t * bytebuffer_create_with_size(size_t size)
Allocate a new bytebuffer_t.
size_t bytebuffer_getlength(const bytebuffer_t *s)
Returns the length of the current buffer.
int64_t varint_s64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
void bytebuffer_append_double(bytebuffer_t *buf, const double val, int swap)
Writes a float64 to the buffer.
bytebuffer_t * bytebuffer_merge(bytebuffer_t **buff_array, int nbuffers)
Returns a new bytebuffer were both ingoing bytebuffers is merged.
void bytebuffer_reset_reading(bytebuffer_t *s)
Set the read cursor to the beginning.
void bytebuffer_clear(bytebuffer_t *s)
Reset the bytebuffer_t.
void bytebuffer_append_uvarint(bytebuffer_t *b, const uint64_t val)
Writes a unsigned varInt to the buffer.
#define BYTEBUFFER_STARTSIZE
void bytebuffer_destroy(bytebuffer_t *s)
Free the bytebuffer_t and all memory managed within it.
void bytebuffer_init_with_size(bytebuffer_t *s, size_t size)
Allocate just the internal buffer of an existing bytebuffer_t struct.
uint64_t varint_u64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
void bytebuffer_append_bulk(bytebuffer_t *s, void *start, size_t size)
Writes a uint8_t value to the buffer.
const uint8_t * bytebuffer_get_buffer(const bytebuffer_t *s, size_t *buffer_length)
Returns a read-only reference to the internal buffer.
uint8_t * bytebuffer_get_buffer_copy(const bytebuffer_t *s, size_t *buffer_length)
Returns a copy of the internal buffer.
size_t varint_u64_encode_buf(uint64_t val, uint8_t *buf)
void * lwrealloc(void *mem, size_t size)
void bytebuffer_append_int(bytebuffer_t *buf, const int val, int swap)
size_t varint_s64_encode_buf(int64_t val, uint8_t *buf)
uint64_t bytebuffer_read_uvarint(bytebuffer_t *b)
Reads a unsigned varInt from the buffer.
void * lwalloc(size_t size)
#define LWDEBUGF(level, msg,...)
static void bytebuffer_makeroom(bytebuffer_t *s, size_t size_to_add)
If necessary, expand the bytebuffer_t internal buffer to accomodate the specified additional size...
void bytebuffer_append_varint(bytebuffer_t *b, const int64_t val)
Writes a signed varInt to the buffer.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
void bytebuffer_destroy_buffer(bytebuffer_t *s)
Free the bytebuffer_t and all memory managed within it.