Commit 8a0153b487d8efa1bbfe97ad4802f530bbebb10b

Thomas de Grivel 2024-03-01T12:04:20

remove <err.h> from set_item.c.in

diff --git a/libc3/set_item.c.in b/libc3/set_item.c.in
index 312e28b..6b14a57 100644
--- a/libc3/set_item.c.in
+++ b/libc3/set_item.c.in
@@ -11,8 +11,7 @@
  * THIS SOFTWARE.
  */
 /* Gen from set_item.c.in NAME=_NAME$ TYPE=_TYPE$ */
-#include <assert.h>
-#include <err.h>
+#include "assert.h"
 #include <stdlib.h>
 #include "set_item___NAME$.h"
 #include "_NAME$.h"
@@ -21,9 +20,16 @@ s_set_item___NAME$ *
 set_item_new___NAME$ (const _TYPE$ *data, uw hash, s_set_item___NAME$ *next)
 {
   s_set_item___NAME$ *item;
-  if (! (item = malloc(sizeof(s_set_item___NAME$))))
-    errx(1, "set_item_new___NAME$: out of memory");
-  _NAME$_init_copy(&item->data, data);
+  item = malloc(sizeof(s_set_item___NAME$));
+  if (! item) {
+    err_puts("set_item_new___NAME$: out of memory");
+    assert(! "set_item_new___NAME$: out of memory");
+    return NULL;
+  }
+  if (! _NAME$_init_copy(&item->data, data)) {
+    free(item);
+    return NULL;
+  }
   item->hash = hash;
   item->next = next;
   item->usage = 0;
diff --git a/libc3/set_item__fact.c b/libc3/set_item__fact.c
index da1643d..175a407 100644
--- a/libc3/set_item__fact.c
+++ b/libc3/set_item__fact.c
@@ -11,8 +11,7 @@
  * THIS SOFTWARE.
  */
 /* Gen from set_item.c.in NAME=fact TYPE=s_fact */
-#include <assert.h>
-#include <err.h>
+#include "assert.h"
 #include <stdlib.h>
 #include "set_item__fact.h"
 #include "fact.h"
@@ -21,9 +20,16 @@ s_set_item__fact *
 set_item_new__fact (const s_fact *data, uw hash, s_set_item__fact *next)
 {
   s_set_item__fact *item;
-  if (! (item = malloc(sizeof(s_set_item__fact))))
-    errx(1, "set_item_new__fact: out of memory");
-  fact_init_copy(&item->data, data);
+  item = malloc(sizeof(s_set_item__fact));
+  if (! item) {
+    err_puts("set_item_new__fact: out of memory");
+    assert(! "set_item_new__fact: out of memory");
+    return NULL;
+  }
+  if (! fact_init_copy(&item->data, data)) {
+    free(item);
+    return NULL;
+  }
   item->hash = hash;
   item->next = next;
   item->usage = 0;
diff --git a/libc3/set_item__tag.c b/libc3/set_item__tag.c
index 95afa4c..6549740 100644
--- a/libc3/set_item__tag.c
+++ b/libc3/set_item__tag.c
@@ -11,8 +11,7 @@
  * THIS SOFTWARE.
  */
 /* Gen from set_item.c.in NAME=tag TYPE=s_tag */
-#include <assert.h>
-#include <err.h>
+#include "assert.h"
 #include <stdlib.h>
 #include "set_item__tag.h"
 #include "tag.h"
@@ -21,9 +20,16 @@ s_set_item__tag *
 set_item_new__tag (const s_tag *data, uw hash, s_set_item__tag *next)
 {
   s_set_item__tag *item;
-  if (! (item = malloc(sizeof(s_set_item__tag))))
-    errx(1, "set_item_new__tag: out of memory");
-  tag_init_copy(&item->data, data);
+  item = malloc(sizeof(s_set_item__tag));
+  if (! item) {
+    err_puts("set_item_new__tag: out of memory");
+    assert(! "set_item_new__tag: out of memory");
+    return NULL;
+  }
+  if (! tag_init_copy(&item->data, data)) {
+    free(item);
+    return NULL;
+  }
   item->hash = hash;
   item->next = next;
   item->usage = 0;