about summary refs log tree commit diff
path: root/lib/util/mallocvar.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util/mallocvar.h')
-rw-r--r--lib/util/mallocvar.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/util/mallocvar.h b/lib/util/mallocvar.h
index 1f2be127..a97b5a00 100644
--- a/lib/util/mallocvar.h
+++ b/lib/util/mallocvar.h
@@ -107,6 +107,21 @@ do { \
         abort(); \
 } while(0)
 
+#define MALLOCARRAY2(arrayName, nRows, nCols, elementSz) do { \
+    void * array; \
+    mallocarray2(&array, nRows, nCols, sizeof(arrayName[0][0]));  \
+    arrayName = array; \
+} while (0)
+
+#define MALLOCARRAY2_NOFAIL(arrayName, nRows, nCols, elementSz) do { \
+    MALLOCARRAY_NOFAIL(arrayName, nRows, nCols, elementSz);       \
+    if ((arrayName) == NULL) \
+        abort(); \
+} while (0)
+
+void
+pm_freearray2(void ** const rowIndex);
+
 
 #define MALLOCVAR(varName) \
     varName = malloc(sizeof(*varName))
@@ -114,6 +129,12 @@ do { \
 #define MALLOCVAR_NOFAIL(varName) \
     do {if ((varName = malloc(sizeof(*varName))) == NULL) abort();} while(0)
 
+void
+pm_mallocarray2(void **      const resultP,
+                unsigned int const cols,
+                unsigned int const rows,
+                unsigned int const elementSize);
+
 #ifdef __cplusplus
 }
 #endif