about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/libpbm1.c20
-rw-r--r--lib/pbm.h4
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/libpbm1.c b/lib/libpbm1.c
index 45989116..c559c373 100644
--- a/lib/libpbm1.c
+++ b/lib/libpbm1.c
@@ -18,8 +18,26 @@
 
 #include <stdio.h>
 
-#include "pbm.h"
+#include "mallocvar.h"
 #include "shhopt.h"
+#include "pbm.h"
+
+
+
+bit *
+pbm_allocrow(unsigned int const cols) {
+
+    bit * bitrow;
+
+    MALLOCARRAY(bitrow, cols);
+
+    if (bitrow == NULL)
+        pm_error("Unable to allocate space for a %u-column bit row", cols);
+
+    return bitrow;
+}
+
+
 
 void
 pbm_init(int *   const argcP,
diff --git a/lib/pbm.h b/lib/pbm.h
index 43c9c062..1c3fedc5 100644
--- a/lib/pbm.h
+++ b/lib/pbm.h
@@ -40,9 +40,11 @@ pbm_init(int *   const argcP,
 void
 pbm_nextimage(FILE *file, int * const eofP);
 
+bit *
+pbm_allocrow(unsigned int const cols);
+
 #define pbm_allocarray(cols, rows) \
   ((bit**) pm_allocarray(cols, rows, sizeof(bit)))
-#define pbm_allocrow(cols) ((bit*) pm_allocrow(cols, sizeof(bit)))
 #define pbm_freearray(bits, rows) pm_freearray((char**) bits, rows)
 #define pbm_freerow(bitrow) pm_freerow((char*) bitrow)
 #define pbm_packed_bytes(cols) (((cols)+7)/8)