Commit 971a739e7365e58721baa21265072e8e5da7990c

Thomas de Grivel 2024-03-02T16:55:52

alloc

diff --git a/libc3/skiplist_node.c.in b/libc3/skiplist_node.c.in
index 0c95235..28720c6 100644
--- a/libc3/skiplist_node.c.in
+++ b/libc3/skiplist_node.c.in
@@ -11,8 +11,8 @@
  * THIS SOFTWARE.
  */
 /* Gen from skiplist_node.c.in NAME=_NAME$ TYPE=_TYPE$ */
-#include <stdlib.h>
 #include <string.h>
+#include "alloc.h"
 #include "skiplist_node___NAME$.h"
 
 s_skiplist_node___NAME$ *
@@ -28,9 +28,11 @@ skiplist_node_init (s_skiplist_node___NAME$ *node, _TYPE$ _NAME$, u8 height)
 s_skiplist_node___NAME$ *
 skiplist_node_new___NAME$ (_TYPE$ _NAME$, u8 height)
 {
-  s_skiplist_node___NAME$ *node = malloc(SKIPLIST_NODE_SIZE___NAME$(height));
-  if (node)
-    skiplist_node_init(node, _NAME$, height);
+  s_skiplist_node___NAME$ *node;
+  node = alloc(SKIPLIST_NODE_SIZE___NAME$(height));
+  if (! node)
+    return NULL;
+  skiplist_node_init(node, _NAME$, height);
   return node;
 }
 
diff --git a/libc3/skiplist_node__fact.c b/libc3/skiplist_node__fact.c
index a14a8eb..eb84eeb 100644
--- a/libc3/skiplist_node__fact.c
+++ b/libc3/skiplist_node__fact.c
@@ -11,8 +11,8 @@
  * THIS SOFTWARE.
  */
 /* Gen from skiplist_node.c.in NAME=fact TYPE=s_fact * */
-#include <stdlib.h>
 #include <string.h>
+#include "alloc.h"
 #include "skiplist_node__fact.h"
 
 s_skiplist_node__fact *
@@ -28,9 +28,11 @@ skiplist_node_init (s_skiplist_node__fact *node, s_fact * fact, u8 height)
 s_skiplist_node__fact *
 skiplist_node_new__fact (s_fact * fact, u8 height)
 {
-  s_skiplist_node__fact *node = malloc(SKIPLIST_NODE_SIZE__fact(height));
-  if (node)
-    skiplist_node_init(node, fact, height);
+  s_skiplist_node__fact *node;
+  node = alloc(SKIPLIST_NODE_SIZE__fact(height));
+  if (! node)
+    return NULL;
+  skiplist_node_init(node, fact, height);
   return node;
 }