changeset 304:61884ce9db41 dev-0_9_2

Use th_vputch() and th_vputs() instead of similar routines in libnnchat.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 11 Jun 2011 05:10:30 +0300
parents 859578ec3275
children 6918c46015d0
files libnnchat.c
diffstat 1 files changed, 2 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- 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)
 {