Commit 59535c3d8f39271091a58ea622cad4ae7eeff42a

Thomas de Grivel 2024-12-26T22:52:49

wip alloc_map

diff --git a/libkc3/env.c b/libkc3/env.c
index a9daac3..5cd2476 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -11,6 +11,7 @@
  * THIS SOFTWARE.
  */
 #include <string.h>
+#include <sys/types.h>
 
 #if (defined(__APPLE__) ||      \
      defined(__FreeBSD__) ||    \
@@ -21,7 +22,6 @@
 #include <sys/sysinfo.h>
 #endif
 
-#include <sys/types.h>
 #include <unistd.h>
 #include "alloc.h"
 #include "array.h"
@@ -953,16 +953,16 @@ bool env_eval_complex (s_env *env, s_complex *c, s_tag *dest)
   assert(env);
   assert(c);
   assert(dest);
-  tmp = alloc(sizeof(s_complex));
+  tmp = alloc_map(sizeof(s_complex));
   if (! tmp)
     return false;
   if (! env_eval_tag(env, &c->x, &tmp->x)) {
-    free(tmp);
+    alloc_unmap(tmp, sizeof(s_complex));
     return false;
   }
   if (! env_eval_tag(env, &c->y, &tmp->y)) {
     tag_clean(&tmp->x);
-    free(tmp);
+    alloc_unmap(tmp, sizeof(s_complex));
     return false;
   }
   dest->type = TAG_COMPLEX;
@@ -981,7 +981,7 @@ bool env_eval_cow (s_env *env, s_cow *cow, s_tag *dest)
     return false;
   if (! env_eval_tag(env, cow_read_only(cow),
                      cow_read_write(tmp))) {
-    free(tmp);
+    cow_delete(tmp);
     return false;
   }
   cow_freeze(tmp);
@@ -1850,14 +1850,14 @@ bool env_eval_quote_time (s_env *env, s_time *time, s_tag *dest)
     if (! env_eval_quote_tag(env, time->tag, tmp.tag)) {
       err_puts("env_eval_quote_time: env_eval_quote_tag: tv_sec");
       assert(! "env_eval_quote_time: env_eval_quote_tag: tv_sec");
-      free(tmp.tag);
+      alloc_unmap(tmp.tag, sizeof(s_tag) * 2);
       return false;
     }
     if (! env_eval_quote_tag(env, time->tag + 1, tmp.tag + 1)) {
       err_puts("env_eval_quote_time: env_eval_quote_tag: tv_nsec");
       assert(! "env_eval_quote_time: env_eval_quote_tag: tv_nsec");
       tag_clean(tmp.tag);
-      free(tmp.tag);
+      alloc_unmap(tmp.tag, sizeof(s_tag) * 2);
       return false;
     }
   }