symtable: refactor for SV changes and propagate

This commit is contained in:
2026-02-11 07:48:28 +00:00
committed by oreodave
parent 3e7734037c
commit b91e79933b
3 changed files with 7 additions and 4 deletions

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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);