diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-07-10 19:37:40 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-07-11 15:49:14 +0200 |
commit | 559eff22d201f0dfa16198ae7724f173f1ea948c (patch) | |
tree | 6431c46153a93b609052b72cd62971372fed980b | |
parent | e5e7e6277cc757475ad192f70a4b200778e1d8ee (diff) |
types, vm: adjust GC api
Provide separate public ucv_gc() and ucv_freeall() functions to perform
an incremental and complete GC run respectively.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | include/ucode/types.h | 4 | ||||
-rw-r--r-- | types.c | 16 | ||||
-rw-r--r-- | vm.c | 2 |
3 files changed, 18 insertions, 4 deletions
diff --git a/include/ucode/types.h b/include/ucode/types.h index e2cb15d..da19f9b 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -434,6 +434,8 @@ ucv_clear_mark(uc_value_t *uv) bool ucv_equal(uc_value_t *, uc_value_t *); -void ucv_gc(uc_vm_t *, bool); +void ucv_gc(uc_vm_t *); + +void ucv_freeall(uc_vm_t *); #endif /* __TYPES_H_ */ @@ -1756,8 +1756,8 @@ ucv_equal(uc_value_t *uv1, uc_value_t *uv2) } } -void -ucv_gc(uc_vm_t *vm, bool final) +static void +ucv_gc_common(uc_vm_t *vm, bool final) { uc_weakref_t *ref, *tmp; uc_value_t *val; @@ -1798,3 +1798,15 @@ ucv_gc(uc_vm_t *vm, bool final) } } } + +void +ucv_gc(uc_vm_t *vm) +{ + ucv_gc_common(vm, false); +} + +void +ucv_freeall(uc_vm_t *vm) +{ + ucv_gc_common(vm, true); +} @@ -183,7 +183,7 @@ void uc_vm_free(uc_vm_t *vm) printbuf_free(vm->strbuf); - ucv_gc(vm, true); + ucv_freeall(vm); for (i = 0; i < vm->restypes.count; i++) free(vm->restypes.entries[i]); |