40 end = buf + ((
sizeof(char) * (len - 1)));
44 while(c <= end && *c !=
'\0') c++;
50 *dest = strdup(&(buf[*source]));
53 *source += strlen(*dest) + 1;
58 int ser_int_get(
int *dest,
int *source,
const char *buf,
int len)
68 if(&(buf[*source]) +
sizeof(int) > buf + (
sizeof(
char) * len))
72 for(i = 0; i <
sizeof(int); i++)
74 u.c[i] = buf[*source];
91 #define BLOCKSIZE 1024
103 while((nblocks = realloc(*oblocks, nlen)) == NULL) sleep(1);
109 #define SER_SAFE(blocks, size, len) if((size) > len) len = _ser_realloc((void**)&(blocks),(size));
113 int need =
sizeof(char) * (strlen(source) + 1);
119 strcpy(*buf + *dest, source);
135 SER_SAFE(*buf, *dest +
sizeof(
int), *len)
139 for(i = 0; i <
sizeof(int); i++)
140 (*buf)[*dest + i] = u.c[i];
143 *dest +=
sizeof(int);
int ser_int_get(int *dest, int *source, const char *buf, int len)
static int _ser_realloc(void **oblocks, int len)
internal: do and return the math and ensure it gets realloc'd
void ser_int_set(int source, int *dest, char **buf, int *len)
void ser_string_set(const char *source, int *dest, char **buf, int *len)
#define SER_SAFE(blocks, size, len)
this is the safety check used to make sure there's always enough mem
int ser_string_get(char **dest, int *source, const char *buf, int len)