lisp: sys_cost for memory footprint

This commit is contained in:
2026-02-11 07:56:57 +00:00
committed by oreodave
parent ff512986f8
commit 8b2fe97fc2
2 changed files with 8 additions and 0 deletions

View File

@@ -34,6 +34,9 @@ void sys_init(sys_t *);
void sys_register(sys_t *, lisp_t *);
void sys_free(sys_t *);
// Debugging function: provides total memory usage from system.
u64 sys_cost(sys_t *);
/// Constructors and destructors
lisp_t *make_int(i64);
lisp_t *make_vec(sys_t *, u64);

View File

@@ -22,6 +22,11 @@ void sys_register(sys_t *sys, lisp_t *ptr)
vec_append(&sys->memory, &ptr, sizeof(&ptr));
}
u64 sys_cost(sys_t *sys)
{
return sym_table_cost(&sys->symtable) + sys->memory.capacity;
}
void sys_free(sys_t *sys)
{
static_assert(NUM_TAGS == 5);