symtable: refactor for SV changes and propagate
This commit is contained in:
@@ -21,7 +21,7 @@ typedef struct
|
||||
#define SYM_TABLE_INIT_SIZE (1 << 10)
|
||||
|
||||
void sym_table_init(sym_table_t *);
|
||||
char *sym_table_find(sym_table_t *, sv_t);
|
||||
const char *sym_table_find(sym_table_t *, sv_t);
|
||||
void sym_table_free(sym_table_t *);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -71,7 +71,7 @@ lisp_t *make_vec(sys_t *sys, u64 capacity)
|
||||
|
||||
lisp_t *intern(sys_t *sys, sv_t sv)
|
||||
{
|
||||
char *str = sym_table_find(&sys->symtable, sv);
|
||||
const char *str = sym_table_find(&sys->symtable, sv);
|
||||
return tag_sym(str);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ void sym_table_init(sym_table_t *table)
|
||||
vec_init(&table->entries, table->capacity * sizeof(sv_t));
|
||||
}
|
||||
|
||||
char *sym_table_find(sym_table_t *table, sv_t sv)
|
||||
const char *sym_table_find(sym_table_t *table, sv_t sv)
|
||||
{
|
||||
// Initialise the table if it's not done already
|
||||
if (table->entries.capacity == 0)
|
||||
@@ -62,7 +62,10 @@ void sym_table_free(sym_table_t *table)
|
||||
{
|
||||
current = ENTRY_GET(table, i);
|
||||
if (current.data)
|
||||
free(current.data);
|
||||
{
|
||||
// NOTE: We clone all data here, so it's okay to free by hand.
|
||||
free((void *)current.data);
|
||||
}
|
||||
}
|
||||
// Free the underlying container
|
||||
vec_free(&table->entries);
|
||||
|
||||
Reference in New Issue
Block a user