X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Farray.c;h=4cc793f18c02b3f4bea6dd1f46ed2914441740a5;hp=81569ce07e1f45ebab4cb4a925b4d498d2e006bd;hb=798de94d6556bdf2c6019f368ad7441fe6e2d1be;hpb=03628dbeaf40a9de34b3eb6d5bf6dd34eed8248c diff --git a/src/ngircd/array.c b/src/ngircd/array.c index 81569ce0..4cc793f1 100644 --- a/src/ngircd/array.c +++ b/src/ngircd/array.c @@ -14,21 +14,23 @@ * Functions to dynamically allocate arrays. */ +/* Additionan debug messages related to array handling: 0=off / 1=on */ +#define DEBUG_ARRAY 0 + #include "array.h" #include - #include #include +#include -#include "log.h" - -/* Enable more Debug messages in alloc / append / memmove code. */ -/* #define DEBUG_ARRAY */ +#if DEBUG_ARRAY +# include "log.h" +#endif +#define array_UNUSABLE(x) ( !(x)->mem ) -#define array_UNUSABLE(x) ( !(x)->mem ) static bool safemult_sizet(size_t a, size_t b, size_t *res) { @@ -65,7 +67,7 @@ array_alloc(array * a, size_t size, size_t pos) return NULL; if (a->allocated < alloc) { -#ifdef DEBUG_ARRAY +#if DEBUG_ARRAY Log(LOG_DEBUG, "array_alloc(): changing size from %u to %u bytes.", a->allocated, alloc); #endif @@ -166,7 +168,7 @@ array_catb(array * dest, const char *src, size_t len) assert(ptr != NULL); -#ifdef DEBUG_ARRAY +#if DEBUG_ARRAY Log(LOG_DEBUG, "array_catb(): appending %u bytes to array (now %u bytes in array).", len, tmp); @@ -246,7 +248,7 @@ void array_free(array * a) { assert(a != NULL); -#ifdef DEBUG_ARRAY +#if DEBUG_ARRAY Log(LOG_DEBUG, "array_free(): %u bytes free'd (%u bytes still used at time of free()).", a->allocated, a->used); @@ -312,7 +314,7 @@ array_moveleft(array * a, size_t membersize, size_t pos) if (!bytepos) return; /* nothing to do */ -#ifdef DEBUG_ARRAY +#if DEBUG_ARRAY Log(LOG_DEBUG, "array_moveleft(): %u bytes used in array, starting at position %u.", a->used, bytepos);