Commit 022cd1f8e73cc91c7df89b65c2deabb9d06bbd7f

Thomas de Grivel 2022-11-07T11:31:42

eval is evil

diff --git a/libc3/error_handler.c b/libc3/error_handler.c
new file mode 100644
index 0000000..c5fbc2e
--- /dev/null
+++ b/libc3/error_handler.c
@@ -0,0 +1,57 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted
+ * the above copyright notice and this permission paragraph
+ * are included in all copies and substantial portions of this
+ * software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <err.h>
+#include <stdlib.h>
+#include "error_handler.h"
+
+void error_handler_clean (s_error_handler *error_handler)
+{
+  assert(error_handler);
+  (void) error_handler;  
+}
+
+void error_handler_delete (s_error_handler *error_handler)
+{
+  assert(error_handler);
+  error_handler_clean(error_handler);
+  free(error_handler);
+}
+
+void error_handler_delete_all (s_error_handler *error_handler)
+{
+  s_error_handler *next;
+  while (error_handler) {
+    next = error_handler->next;
+    error_handler_delete(error_handler);
+    error_handler = next;
+  }
+}
+
+s_error_handler *
+error_handler_init (s_error_handler *error_handler,
+                    s_error_handler *next)
+{
+  assert(error_handler);
+  error_handler->next = next;
+  return error_handler;
+}
+
+s_error_handler * error_handler_new (s_error_handler *next)
+{
+  s_error_handler *error_handler;
+  if (! (error_handler = malloc(sizeof(s_error_handler))))
+    errx(1, "error_handler_new: out of memory");
+  return error_handler_init(error_handler, next);
+}
diff --git a/libc3/eval.c b/libc3/eval.c
new file mode 100644
index 0000000..42542fd
--- /dev/null
+++ b/libc3/eval.c
@@ -0,0 +1,22 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted
+ * the above copyright notice and this permission paragraph
+ * are included in all copies and substantial portions of this
+ * software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include "env.h"
+#include "eval.h"
+#include "tag.h"
+
+s_tag * eval_tag (s_env *env, s_tag *dest, s_tag *tag)
+{
+  (void) env;
+  return tag_copy(tag, dest);
+}
diff --git a/libc3/eval.h b/libc3/eval.h
index 169ccf0..0c37a24 100644
--- a/libc3/eval.h
+++ b/libc3/eval.h
@@ -16,6 +16,6 @@
 
 #include "types.h"
 
-s_tag * eval_tag (s_env *env, s_tag *tag);
+s_tag * eval_tag (s_env *env, s_tag *dest, s_tag *tag);
 
 #endif /* EVAL_H */
diff --git a/libc3/frame.c b/libc3/frame.c
index 903ebbf..9205298 100644
--- a/libc3/frame.c
+++ b/libc3/frame.c
@@ -25,8 +25,10 @@ void frame_clean (s_frame *frame)
 
 void frame_delete (s_frame *frame)
 {
-  if (frame)
+  if (frame) {
     frame_clean(frame);
+    free(frame);
+  }
 }
 
 void frame_delete_all (s_frame *frame)
diff --git a/test/facts_test_dump.facts.expected b/test/facts_test_dump.facts.expected
index bebffb3..1a5c4fa 100644
--- a/test/facts_test_dump.facts.expected
+++ b/test/facts_test_dump.facts.expected
@@ -21,3 +21,4 @@ add {{a, b}, {a, b}, {a, b}}
 add {{:a, :b}, {:a, :b}, {:a, :b}}
 add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
 add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+x
diff --git a/test/facts_test_log_add.facts.expected b/test/facts_test_log_add.facts.expected
index 5286f7a..3ae74d1 100644
--- a/test/facts_test_log_add.facts.expected
+++ b/test/facts_test_log_add.facts.expected
@@ -21,3 +21,4 @@ add {-256, -256, -256}
 add {-65536, -65536, -65536}
 add {-4294967296, -4294967296, -4294967296}
 add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
+x
diff --git a/test/facts_test_log_remove.facts.expected b/test/facts_test_log_remove.facts.expected
index f96c838..068650e 100644
--- a/test/facts_test_log_remove.facts.expected
+++ b/test/facts_test_log_remove.facts.expected
@@ -44,3 +44,4 @@ remove {a, a, a}
 remove {A, A, A}
 remove {:a, :a, :a}
 remove {"a", "a", "a"}
+x