X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Farray.c;h=ad4f8dac7cda4a57fd5f57a4901829872900e4ac;hp=75106f623926edb8c85cf2736d3aaf67325761a5;hb=808c291c76b7ecb4ae13b6ee12e8afe658b627c1;hpb=994a003aba9aac4a8adca7f4f4fec0889b0f2bb1 diff --git a/src/ngircd/array.c b/src/ngircd/array.c index 75106f62..ad4f8dac 100644 --- a/src/ngircd/array.c +++ b/src/ngircd/array.c @@ -5,17 +5,18 @@ * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. * - * functions to dynamically allocate arrays. + * libarray - dynamically allocate arrays. * Copyright (c) 2005 Florian Westphal (westphal@foo.fh-furtwangen.de) - * */ -#include "array.h" +/** + * @file + * Functions to dynamically allocate arrays. + */ -static char UNUSED id[] = "$Id: array.c,v 1.15 2007/11/18 15:05:35 alex Exp $"; +#include "array.h" #include - #include #include @@ -24,9 +25,9 @@ static char UNUSED id[] = "$Id: array.c,v 1.15 2007/11/18 15:05:35 alex Exp $"; /* Enable more Debug messages in alloc / append / memmove code. */ /* #define DEBUG_ARRAY */ +#define array_UNUSABLE(x) ( !(x)->mem ) -#define array_UNUSABLE(x) ( !(x)->mem || (0 == (x)->allocated) ) static bool safemult_sizet(size_t a, size_t b, size_t *res) { @@ -93,6 +94,7 @@ array_length(const array * const a, size_t membersize) if (array_UNUSABLE(a)) return 0; + assert(a->allocated); return membersize ? a->used / membersize : 0; } @@ -104,6 +106,7 @@ array_copy(array * dest, const array * const src) if (array_UNUSABLE(src)) return false; + assert(src->allocated); return array_copyb(dest, src->mem, src->used); }