Commit 01ee6b0ef12776f5eb5b730177552561b762b5ae

Thomas de Grivel 2023-08-11T09:23:25

clean

diff --git a/libc3/call.c b/libc3/call.c
index 4994ab6..9478e8a 100644
--- a/libc3/call.c
+++ b/libc3/call.c
@@ -16,6 +16,7 @@
 #include "buf_inspect.h"
 #include "buf_parse.h"
 #include "call.h"
+#include "cfn.h"
 #include "ident.h"
 #include "list.h"
 
@@ -23,6 +24,8 @@ void call_clean (s_call *call)
 {
   assert(call);
   list_delete_all(call->arguments);
+  if (call->cfn)
+    cfn_delete(call->cfn);
 }
 
 s_call * call_copy (const s_call *src, s_call *dest)
diff --git a/libc3/cfn.c b/libc3/cfn.c
index 6bea741..28c2bc7 100644
--- a/libc3/cfn.c
+++ b/libc3/cfn.c
@@ -126,6 +126,13 @@ s_cfn * cfn_copy (const s_cfn *cfn, s_cfn *dest)
   return dest;
 }
 
+void cfn_delete (s_cfn *cfn)
+{
+  assert(cfn);
+  cfn_clean(cfn);
+  free(cfn);
+}
+
 s_cfn * cfn_init (s_cfn *cfn, const s_sym *name, s_list *arg_types,
                   const s_sym *result_type)
 {
diff --git a/libc3/cfn.h b/libc3/cfn.h
index 285c49d..6905b6b 100644
--- a/libc3/cfn.h
+++ b/libc3/cfn.h
@@ -20,7 +20,8 @@ s_cfn * cfn_init (s_cfn *cfn, const s_sym *name, s_list *arg_types,
                   const s_sym *result_type);
 void    cfn_clean (s_cfn *cfn);
 
-/* constructor */
+/* constructor, destructor */
+void    cfn_delete (s_cfn *cfn);
 s_cfn * cfn_new_copy (const s_cfn *src);
 
 /* observers */