diff --git a/lib.c b/lib.c index 14e7076..27b1302 100644 --- a/lib.c +++ b/lib.c @@ -1300,6 +1300,7 @@ void ink_gc(struct context* ctx) { int i, j, k; int marked; struct element_slab* v; + struct elem* thing; for(i = 0; i < ctx->types_top; ++i) { for(j = 0; j < ctx->types[i].elements_top; ++j) { @@ -1329,11 +1330,20 @@ void ink_gc(struct context* ctx) { continue; } else for(j = 0; j < ctx->routines[i].top; ++j) { v = ink_get_value_link(ctx, ctx->routines[i].stack[j]); - if(v != NULL) ++v->uses; + if(v != NULL && !v->uses) ++v->uses; } } - /* TODO: Mark objects contained within function code */ + for(i = 0; i < ctx->native_words_top; ++i) { + struct fn* function = ctx->words + i; + for(j = 0; j < function->size; ++j) { + thing = function->things + j; + v = ink_get_value_link(ctx, *thing); + if (v != NULL && !v->uses) { + ++v->uses; + } + } + } /* Mark the rest of the data */ do {