commit - 6d3686e73dd5df99ee09a3a1f81a89dfa47efab8
commit + 4a2eea2939bc9131f240491355aa40976ca7a38d
blob - d34c00d52ba94b561c488f0b37cdef46722227e9
blob + bc405351e0d5fd825cba4e89f6412b06131a13ba
--- src/ngircd/array.c
+++ src/ngircd/array.c
#include "array.h"
-static char UNUSED id[] = "$Id: array.c,v 1.8 2005/08/30 13:36:32 fw Exp $";
+static char UNUSED id[] = "$Id: array.c,v 1.9 2006/05/07 10:52:47 fw Exp $";
#include <assert.h>
#include "log.h"
-#define array_UNUSABLE(x) ( ! x->mem || (0 == x->allocated) )
+#define array_UNUSABLE(x) ( !(x)->mem || (0 == (x)->allocated) )
-#define ALIGN_32U(x) ((x | 0x1fU) +1)
-#define ALIGN_1024U(x) ((x | 0x3ffU) +1)
-#define ALIGN_4096U(x) ((x | 0xfffU) +1)
+#define ALIGN_32U(x) (((x) | 0x1fU) +1)
+#define ALIGN_1024U(x) (((x) | 0x3ffU) +1)
+#define ALIGN_4096U(x) (((x) | 0xfffU) +1)
static bool
safemult_sizet(size_t a, size_t b, size_t *res)
{
size_t tmp;
-
- if (!a || !b) {
- *res = 0;
- return true;
- }
-
+
tmp = a * b;
- if (tmp / b != a)
+ if (b && (tmp / b != a))
return false;
*res = tmp;
void
array_init(array *a)
{
- assert(a);
+ assert(a != NULL);
a->mem = NULL;
a->allocated = 0;
a->used = 0;