diff options
author | Brian Cully <bjc@kublai.com> | 2008-04-14 21:54:00 -0400 |
---|---|---|
committer | Brian Cully <github.20.shmit@spamgourmet.com> | 2008-04-14 21:54:00 -0400 |
commit | 79d65188b1c1578a36403c0e5756c81dcc93d816 (patch) | |
tree | 2903ed400cd0ebd13350397d402c1d9d5b9f869d /server/.svn/text-base/array.c.svn-base | |
parent | 6ba98a9f9f48e13738d9736cba9c45b5e94f42f2 (diff) | |
download | nastd-79d65188b1c1578a36403c0e5756c81dcc93d816.tar.gz nastd-79d65188b1c1578a36403c0e5756c81dcc93d816.zip |
Remove svn files
Diffstat (limited to 'server/.svn/text-base/array.c.svn-base')
-rw-r--r-- | server/.svn/text-base/array.c.svn-base | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/server/.svn/text-base/array.c.svn-base b/server/.svn/text-base/array.c.svn-base deleted file mode 100644 index 65766de..0000000 --- a/server/.svn/text-base/array.c.svn-base +++ /dev/null @@ -1,149 +0,0 @@ -#include "conf.h" -#include "array.h" -#include "log.h" - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -RCSID("$Id: array.c,v 1.10 2000/10/17 23:38:27 shmit Exp $"); - -string_t * -string_new(int slen, char *strdata) -{ - string_t *tmp; - - tmp = malloc(sizeof(string_t)); - if (tmp == NULL) { - log_err("Couldn't allocate data for string: %s.", - strerror(errno)); - return NULL; - } - - tmp->str = malloc(slen * sizeof(char *)); - if (tmp->str == NULL) { - log_err("Couldn't allocate string data: %s.", - strerror(errno)); - return NULL; - } - memcpy(tmp->str, strdata, slen); - tmp->strlen = slen; - - return tmp; -} - -void -string_delete(string_t *string) -{ - if (string == NULL) - return; - - if (string->str != NULL) - free(string->str); - string->strlen = 0; - string->str = NULL; - free(string); -} - -array_t * -array_new() -{ - array_t *tmp; - - tmp = malloc(sizeof(array_t)); - if (tmp == NULL) - return NULL; - - tmp->nitems = 0; - tmp->items = NULL; - return tmp; -} - -void -array_delete(array_t *aa) -{ - int i; - - if (aa == NULL) - return; - - for (i = 0; i < aa->nitems; i++) - string_delete(aa->items[i]); - free(aa->items); - aa->items = NULL; - free(aa); -} - -int -va_array_add(array_t *aa, va_list ap) -{ - const int GRANULARITY = 10; - int slen; - char *s; - - slen = va_arg(ap, int); - if (slen != ARRTERM) - s = va_arg(ap, char *); - else - s = NULL; - while (s) { - if (aa->nitems % GRANULARITY == 0) { - aa->items = realloc(aa->items, sizeof(string_t *) * - (GRANULARITY + aa->nitems)); - if (aa->items == NULL) - return -1; - } - aa->nitems++; - aa->items[aa->nitems-1] = string_new(slen, s); - if (aa->items[aa->nitems-1] == NULL) - return -1; - slen = va_arg(ap, int); - if (slen != ARRTERM) - s = va_arg(ap, char *); - else - s = NULL; - } - - return 0; -} - -int -array_add(array_t *aa, ...) -{ - va_list ap; - int rc; - - va_start(ap, aa); - rc = va_array_add(aa, ap); - va_end(ap); - - return rc; -} - -int -array_dup(array_t *dst, array_t *src) -{ - int i; - - if (dst == NULL) - return -1; - - dst->nitems = src->nitems; - dst->items = malloc(dst->nitems * sizeof(string_t *)); - if (dst->items == NULL) { - log_err("Couldn't allocate dup array items list: %s.", - strerror(errno)); - return -1; - } - - for (i = 0; i < dst->nitems; i++) { - dst->items[i] = string_new(src->items[i]->strlen, - src->items[i]->str); - if (dst->items[i] == NULL) { - dst->nitems = i; - return -1; - } - } - - return 0; -} |