18 #ifndef __BUFFER_HPP_INCLUDED__
19 #define __BUFFER_HPP_INCLUDED__
21 #include <ndb_global.h>
30 UtilBuffer() { data = NULL; len = 0; alloc_size = 0; };
31 ~
UtilBuffer() {
if(data) free(data); data = NULL; len = 0; alloc_size = 0; };
34 int reallocate(
size_t newsize) {
40 if((newdata = realloc(data, newsize)) == NULL) {
55 int append(
const void *d,
size_t l) {
61 memcpy((
char *)data+len, d, l);
67 void * append(
size_t l){
71 void *
ret = (
char*)data+len;
76 int assign(
const void * d,
size_t l) {
82 int ret= append(d, l);
92 int length()
const { assert(Uint64(len) == Uint32(len));
return (
int)len; }
94 void *get_data()
const {
return data; }
96 bool empty ()
const {
return len == 0; }
99 if(len==0 && cmp.len==0)
101 else if(len!=cmp.len)
104 return (memcmp(get_data(), cmp.get_data(), len) == 0);
110 ret = assign(buf.get_data(), buf.length());