diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-02 07:32:43 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-02 07:32:43 -0700 |
commit | 6d865f2acdf5f93f06ddd0f4d3ac3a450d36dcd7 (patch) | |
tree | 445660bfb55006bc2277a920edd608b0b5133931 /gc.h | |
parent | 1f4c97f1362f29084f08f7d2199475bbe749eb8e (diff) | |
download | txr-6d865f2acdf5f93f06ddd0f4d3ac3a450d36dcd7.tar.gz txr-6d865f2acdf5f93f06ddd0f4d3ac3a450d36dcd7.tar.bz2 txr-6d865f2acdf5f93f06ddd0f4d3ac3a450d36dcd7.zip |
Fix incorrect finalization of struct-type.
The issue is that we can't call remhash in the cobj destroy
handler, because we are in the middle of gc. The fix is to
register a proper finalization hook. This is the first use of
finalize from within TXR.
* gc.c (gc_finalize): static becomes extern.
* gc.h (gc_finalize): Declared.
* struct.c (struct_type_finalize_f): New static variable.
(struct_init): GC-protect new static variable, and initialize
it to point to new struct_type_finalize function.
(struct_type_finalize): New function: performs the remhash
calls previously done in struct_type_free.
(make_struct_type): Register a finalizer hook for every new
structure type, which will call struct_type_finalize.
(struct_type_free): Static function removed.
(struct_type_ops): Use generic cobj_destroy_free_op since
all that is left to do is to free the handle.
Diffstat (limited to 'gc.h')
-rw-r--r-- | gc.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -35,6 +35,7 @@ int gc_state(int); void gc_mark(val); void gc_conservative_mark(val); int gc_is_reachable(val); +val gc_finalize(val obj, val fun); #if CONFIG_GEN_GC val gc_set(loc, val); |