2018-04-12 23:54:58 -07:00
|
|
|
#include "value.h"
|
2018-04-17 15:49:09 -07:00
|
|
|
#include "parsetype.h"
|
2018-04-12 23:54:58 -07:00
|
|
|
|
|
|
|
void libab_value_init(libab_value* value, void* data, libab_ref* type) {
|
|
|
|
value->data = data;
|
|
|
|
libab_ref_copy(type, &value->type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void libab_value_free(libab_value* value) {
|
|
|
|
void (*free_function)(void*);
|
2018-04-17 15:49:09 -07:00
|
|
|
libab_parsetype* value_type;
|
2018-04-12 23:54:58 -07:00
|
|
|
value_type = libab_ref_get(&value->type);
|
2018-04-17 15:49:09 -07:00
|
|
|
free_function = value_type->data_u.base->free_function;
|
2018-04-24 18:28:31 -07:00
|
|
|
libab_ref_free(&value->type);
|
2018-04-21 14:09:01 -07:00
|
|
|
if (free_function)
|
|
|
|
free_function(value->data);
|
2018-04-12 23:54:58 -07:00
|
|
|
}
|