瀏覽代碼

added a function to collects expended routines

main
Ludovic 'Archivist' Lagouardette 6 天之前
父節點
當前提交
61bc4e6359
共有 2 個文件被更改,包括 22 次插入0 次删除
  1. +6
    -0
      include/ink.h
  2. +16
    -0
      lib.c

+ 6
- 0
include/ink.h 查看文件

@ -338,6 +338,12 @@ struct elem ink_make_transparent(struct context* ctx, int type_id, void* ptr);
*/
void ink_gc(struct context* ctx);
/**
* Cleans up coroutine stacks before reuse
* @param ctx
*/
void ink_clean_routines(struct context* ctx);
/**
* Obtains the type id from the declared name of the type
* @param ctx The context where we want to detect the type

+ 16
- 0
lib.c 查看文件

@ -1153,6 +1153,22 @@ struct elem ink_make_native(struct context* ctx, int type, void* ptr) {
return ink_make_native_unsafe(ctx, type, ptr, 0);
}
void ink_clean_routines(struct context* ctx) {
int i, j;
struct elem null;
null.value = 0;
null.type = INK_INTEGER;
for(i = 0; i < ctx->routines_top; ++i) {
if(ctx->routines[i].panic == INK_ROUTINE_CAN_REUSE) {
for (j = 0; j < ctx->routines[i].top; ++j) {
ctx->routines[i].stack[j] = null;
}
ctx->routines[i].top = 0;
}
}
}
void ink_gc(struct context* ctx) {
int i, j, k;
int marked;

Loading…
取消
儲存