diff --git a/libc3/struct.c b/libc3/struct.c
index 37503ae..89486b4 100644
--- a/libc3/struct.c
+++ b/libc3/struct.c
@@ -27,12 +27,12 @@ s_struct * struct_allocate (s_struct *s)
{
s_struct tmp;
assert(s);
+ assert(s->type);
assert(! s->data);
tmp = *s;
tmp.data = alloc(tmp.type->size);
if (! tmp.data)
return NULL;
- tmp.free_data = true;
*s = tmp;
return s;
}
@@ -54,8 +54,7 @@ void struct_clean (s_struct *s)
i++;
}
}
- if (s->free_data)
- free(s->data);
+ free(s->data);
}
if (s->tag) {
i = 0;
@@ -182,7 +181,6 @@ s_struct * struct_init_copy (s_struct *s, const s_struct *src)
tmp.data = alloc(tmp.type->size);
if (! tmp.data)
return NULL;
- tmp.free_data = true;
i = 0;
while (i < tmp.type->map.count) {
if (! tag_type(tmp.type->map.value + i, &sym) ||
@@ -263,7 +261,7 @@ s_struct * struct_init_from_lists (s_struct *s, const s_sym *module,
}
s_struct * struct_init_with_data (s_struct *s, const s_sym *module,
- bool free_data, void *data)
+ void *data)
{
s_struct tmp = {0};
assert(s);
@@ -276,7 +274,6 @@ s_struct * struct_init_with_data (s_struct *s, const s_sym *module,
err_write_1("\n");
return NULL;
}
- tmp.free_data = free_data;
tmp.data = data;
*s = tmp;
return s;
diff --git a/libc3/struct.h b/libc3/struct.h
index 7250a43..ceb5780 100644
--- a/libc3/struct.h
+++ b/libc3/struct.h
@@ -31,15 +31,14 @@ s_struct * struct_init_from_lists (s_struct *s, const s_sym *module,
const s_list *keys,
const s_list *values);
s_struct * struct_init_with_data (s_struct *s, const s_sym *module,
- bool free_data, void *data);
+ void *data);
/* Heap-allocation functions, call struct_delete after use. */
void struct_delete (s_struct *s);
s_struct * struct_new (const s_sym *module);
s_struct * struct_new_1 (const s8 *p);
s_struct * struct_new_copy (const s_struct *src);
-s_struct * struct_new_with_data (const s_sym *module, bool free_data,
- void *data);
+s_struct * struct_new_with_data (const s_sym *module, void *data);
/* Operators. */
s_struct * struct_allocate (s_struct *s);
diff --git a/libc3/types.h b/libc3/types.h
index af5a9e9..91b4c43 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -297,10 +297,9 @@ struct quote {
};
struct struct_ {
- void *data;
- s_tag *tag;
- bool free_data;
const s_struct_type *type;
+ s_tag *tag;
+ void *data;
};
struct sym_list {