about summary refs log tree commit diff
path: root/lib/util/mallocvar.h
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-06-27 19:52:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-06-27 19:52:28 +0000
commitb64acd496028fb582d052f9e7fccfe6d542f85ca (patch)
treef857dd13be86692b13199c0da7bdfe343b8e30a2 /lib/util/mallocvar.h
parente0d1d6e5f3836c0f5b2bf20a8666b312802a540e (diff)
downloadnetpbm-mirror-b64acd496028fb582d052f9e7fccfe6d542f85ca.tar.gz
netpbm-mirror-b64acd496028fb582d052f9e7fccfe6d542f85ca.tar.xz
netpbm-mirror-b64acd496028fb582d052f9e7fccfe6d542f85ca.zip
Add MALLOCARRAY2
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1249 9d0c8265-081b-0410-96cb-a4ca84ce46f8
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