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.c | |
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.c')
-rw-r--r-- | gc.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -807,7 +807,7 @@ static val gc_wrap(void) return nil; } -static val gc_finalize(val obj, val fun) +val gc_finalize(val obj, val fun) { type_check(fun, FUN); |