commit - 21a067e0b1cd307ff33babe973e9edda6eecd1b3
commit + 20ff63a8a1d92875130a5d6b059e011b1de2201d
blob - f45c0a3aecd29a3d1d6f1471f84488866b55b70a
blob + bbff5a145c937fa125fd507a563890495662c43d
--- src/ngircd/array.c
+++ src/ngircd/array.c
#include "array.h"
-static char UNUSED id[] = "$Id: array.c,v 1.4 2005/07/14 09:14:12 alex Exp $";
+static char UNUSED id[] = "$Id: array.c,v 1.5 2005/07/28 16:12:50 fw Exp $";
#include <assert.h>
return true;
}
+
+void
+array_init(array *a)
+{
+ assert(a);
+ a->mem = NULL;
+ a->allocated = 0;
+ a->used = 0;
+}
+
/* if realloc() fails, array_alloc return NULL. otherwise return pointer to elem pos in array */
void *
}
+/* append trailing NUL byte to array, but do not count it. */
+bool
+array_cat0_temporary(array * a)
+{
+ unsigned int len = array_bytes(a);
+ if (!array_catb(a, "", 1))
+ return false;
+
+ array_truncate(a, 1, len);
+ return true;
+}
+
/* add contents of array src to array dest. */
bool
array_cat(array * dest, const array * const src)
blob - 82ea2f0d78bc9f528d16f924fbcdcf424a56dd49
blob + 236724c545cd277ff77c2a6be50c99f8d27c4c79
--- src/ngircd/array.h
+++ src/ngircd/array.h
* libarray - dynamically allocate arrays.
* Copyright (c) 2005 Florian Westphal (westphal@foo.fh-furtwangen.de)
*
- * $Id: array.h,v 1.2 2005/07/14 09:11:38 alex Exp $
+ * $Id: array.h,v 1.3 2005/07/28 16:12:50 fw Exp $
*/
#ifndef array_h_included
#define array_unallocated(x) (array_bytes(x)==0)
#define INIT_ARRAY { NULL, 0, 0 }
+/* set all variables in a to 0 */
+extern void array_init PARAMS((array *a));
+
/* allocates space for at least nmemb+1 elements of size bytes each.
return pointer to elem at pos, or NULL if realloc() fails */
extern void * array_alloc PARAMS((array *a, unsigned int size, unsigned int pos));
/* append NUL byte to dest */
extern bool array_cat0 PARAMS((array* dest));
+/* append NUL byte to dest, but do not count null byte */
+extern bool array_cat0_temporary PARAMS((array* dest));
+
/* append contents of array src to array dest. */
extern bool array_cat PARAMS((array* dest, const array* const src));