diff --git a/libc3/binding.c b/libc3/binding.c
index 6330bd1..a5830fc 100644
--- a/libc3/binding.c
+++ b/libc3/binding.c
@@ -15,9 +15,12 @@
#include <stdlib.h>
#include "binding.h"
#include "list.h"
+#include "tag.h"
void binding_delete (s_binding *binding)
{
+ assert(binding);
+ tag_clean(&binding->value);
free(binding);
}
@@ -35,7 +38,7 @@ const s_tag * binding_get (const s_binding *binding, const s_sym *name)
{
while (binding) {
if (binding->name == name)
- return binding->value;
+ return &binding->value;
binding = binding->next;
}
return NULL;
@@ -46,7 +49,7 @@ s_binding * binding_init (s_binding *binding, const s_sym *name,
{
assert(binding);
binding->name = name;
- binding->value = value;
+ tag_copy(value, &binding->value);
binding->next = next;
return binding;
}
diff --git a/libc3/types.h b/libc3/types.h
index ecc29ee..607600e 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -248,12 +248,6 @@ struct unwind_protect {
};
/* 2 */
-struct binding {
- const s_sym *name;
- const s_tag *value;
- s_binding *next;
-};
-
struct buf {
sw column;
sw (*flush) (s_buf *buf);
@@ -380,6 +374,12 @@ struct arg {
s_arg *next;
};
+struct binding {
+ const s_sym *name;
+ s_tag value;
+ s_binding *next;
+};
+
struct error_handler
{
s_list *backtrace;