# HG changeset patch # User Matti Hamalainen # Date 1307758230 -10800 # Node ID 61884ce9db41038558af6a7fc5f1b536ed6fb066 # Parent 859578ec3275213b4143a4fa6a9f2975c62c6ad5 Use th_vputch() and th_vputs() instead of similar routines in libnnchat. diff -r 859578ec3275 -r 61884ce9db41 libnnchat.c --- a/libnnchat.c Sat Jun 11 04:50:00 2011 +0300 +++ b/libnnchat.c Sat Jun 11 05:10:30 2011 +0300 @@ -232,38 +232,8 @@ } -static BOOL bufRealloc(char **buf, size_t *size, size_t add) -{ - return ((*buf = th_realloc(*buf, *size + add)) != NULL); -} - -#define PUSHCHAR(x) bufPushChar(&result, &resSize, &resPos, x) -static BOOL bufPushChar(char **buf, size_t *size, size_t *pos, char ch) -{ - if (*pos >= *size && !bufRealloc(buf, size, NN_ALLOC_SIZE)) - return FALSE; - - (*buf)[*pos] = ch; - (*pos)++; - return TRUE; -} - -#define PUSHSTR(x) bufPushStr(&result, &resSize, &resPos, x) -static BOOL bufPushStr(char **buf, size_t *size, size_t *pos, char *str) -{ - size_t tmpLen; - - if (str == NULL) return FALSE; - tmpLen = strlen(str); - - if ((*pos + tmpLen) >= *size && !bufRealloc(buf, size, tmpLen + NN_ALLOC_SIZE)) - return FALSE; - - strcpy(*buf + *pos, str); - (*pos) += tmpLen; - return TRUE; -} - +#define PUSHCHAR(x) th_vputch(&result, &resSize, &resPos, x) +#define PUSHSTR(x) th_vputs(&result, &resSize, &resPos, x) char *nn_encode_str1(const char *str) {