Commit 5315b8062329df3faa72eac56dc7dfd814b2bd82

Thomas de Grivel 2023-04-01T01:39:29

zero dimension

diff --git a/libc3/array.c b/libc3/array.c
index f668547..bb0b402 100644
--- a/libc3/array.c
+++ b/libc3/array.c
@@ -13,6 +13,7 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
 #include "array.h"
 
 void array_clean (s_array *a)
@@ -27,11 +28,12 @@ s_array * array_init (s_array *a, uw dimension, uw *sizes)
   uw i = 0;
   uw sizeof_sizes;
   assert(a);
-  if (! (a->dimension = dimension)) {
-    a->sizes = NULL;
-    a->data = NULL;
-    return a;
+  assert(dimension);
+  if (! dimension) {
+    errx(1, "zero dimension");
+    return NULL;
   }
+  a->dimension = dimension;
   sizeof_sizes = dimension * sizeof(uw *);
   a->sizes = malloc(sizeof_sizes);
   memcpy(a->sizes, sizes, sizeof_sizes);