/******************************************************************************/
-/* postlicyd: a postfix policy daemon with a lot of features */
+/* pfixtools: a collection of postfix related tools */
/* ~~~~~~~~~ */
/* ________________________________________________________________________ */
/* */
* Copyright © 2006 Pierre Habouzit
*/
-#ifndef POSTLICYD_MEM_H
-#define POSTLICYD_MEM_H
+#ifndef PFIXTOOLS_MEM_H
+#define PFIXTOOLS_MEM_H
#include <assert.h>
#include <ctype.h>
#define p_dupstr(p, len) xmemdupstr((p), (len))
#define p_realloc(pp, count) xrealloc((void*)(pp), sizeof(**(pp)) * (count))
+# define p_alloc_nr(x) (((x) + 16) * 3 / 2)
+# define p_allocgrow(pp, goalnb, allocnb) \
+ do { \
+ if ((goalnb) > *(allocnb)) { \
+ if (p_alloc_nr(goalnb) > *(allocnb)) { \
+ *(allocnb) = (goalnb); \
+ } else { \
+ *(allocnb) = p_alloc_nr(goalnb); \
+ } \
+ p_realloc(pp, *(allocnb)); \
+ } \
+ } while (0)
+
#ifdef __GNUC__
# define p_delete(mem_pp) \
} \
}
-#endif /* POSTLICYD_MEM_H */
+#endif /* PFIXTOOLS_MEM_H */