summaryrefslogtreecommitdiffstats
path: root/struct.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-02-28 18:48:44 -0800
committerKaz Kylheku <kaz@kylheku.com>2018-02-28 18:48:44 -0800
commitdf3789cfece5eaa149d76b07eda310c607288fbb (patch)
tree4aa7e08ee185330a3f0f9c418dc7b64265152b1f /struct.c
parent92a40d9b424295ad8f62cad590b3862b1e6a54e0 (diff)
downloadtxr-df3789cfece5eaa149d76b07eda310c607288fbb.tar.gz
txr-df3789cfece5eaa149d76b07eda310c607288fbb.tar.bz2
txr-df3789cfece5eaa149d76b07eda310c607288fbb.zip
bugfix: missing actions in reset-struct.
* struct.c (reset_struct): Perform the post-init actions are performed, not only the init actions. Also, catch exceptions and call finalizers, just like in a new structure instantiation. * txr.1: Document the requirements for finalizers being called by reset-struct, and clarify the issue of possible duplicate finalization registration. Add compat notes.
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/struct.c b/struct.c
index 6178340b..0e8b1080 100644
--- a/struct.c
+++ b/struct.c
@@ -726,14 +726,30 @@ val reset_struct(val strct)
struct struct_inst *si = struct_handle(strct, self);
struct struct_type *st = si->type;
cnum i;
+ volatile val inited = nil;
+ int compat_190 = opt_compat && opt_compat <= 190;
check_init_lazy_struct(strct, si);
+ uw_simple_catch_begin;
+
for (i = 0; i < st->nslots; i++)
si->slot[i] = nil;
call_initfun_chain(st, strct);
+ if (!compat_190)
+ call_postinitfun_chain(st, strct);
+
+ inited = t;
+
+ uw_unwind {
+ if (!inited && !compat_190)
+ gc_call_finalizers(strct);
+ }
+
+ uw_catch_end;
+
return strct;
}