Commit 65089bce4102da8559dceb894c25a703c8c33a66

Thomas de Grivel 2024-12-10T11:26:47

env_fork_delete

diff --git a/libkc3/env_fork.c b/libkc3/env_fork.c
index 460edb1..ba4e8dd 100644
--- a/libkc3/env_fork.c
+++ b/libkc3/env_fork.c
@@ -27,6 +27,13 @@ void env_fork_clean (s_env *env)
   //tmp.unwind_protect = NULL;
 }
 
+void env_fork_delete (s_env *env)
+{
+  assert(env);
+  env_fork_clean(env);
+  free(env);
+}
+
 s_env * env_fork_init (s_env *env, s_env *src)
 {
   s_env tmp = {0};
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index dff3d7e..e01f23f 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -818,6 +818,7 @@ void * kc3_thread_start (void *arg)
   g_kc3_env = env_fork_new((s_env *) tag->data.tuple.tag[2].data.ptr.p);
   if (! eval_callable_call(start, NULL, tag->data.tuple.tag))
     return NULL;
+  env_fork_delete(g_kc3_env);
   return tag;
 }