summaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-04 07:39:32 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-04 07:39:32 +0000
commitd14560a36ff2f0ad8eb26b7c603776a07b63679a (patch)
treef47e9ce8f0c67d0fde2a89046f60ebd0afc5d3dc /gc.c
parentf2bfa4de6abe84baa24db557e67771fd24fb0267 (diff)
downloadruby-d14560a36ff2f0ad8eb26b7c603776a07b63679a.tar.gz
ruby-d14560a36ff2f0ad8eb26b7c603776a07b63679a.tar.xz
ruby-d14560a36ff2f0ad8eb26b7c603776a07b63679a.zip
* object.c (copy_object): copy finalizers as well if any.
* gc.c (rb_gc_copy_finalizer): new function to copy finalizers. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 3f8c4f97b..f925e55e0 100644
--- a/gc.c
+++ b/gc.c
@@ -1475,6 +1475,22 @@ define_final(argc, argv, os)
return proc;
}
+void
+rb_gc_copy_finalizer(dest, obj)
+ VALUE dest, obj;
+{
+ VALUE table;
+
+ if (!finalizer_table) return;
+ if (!FL_TEST(obj, FL_FINALIZE)) return;
+ if (FL_TEST(dest, FL_FINALIZE)) {
+ rb_warn("copy_finalizer: descarding old finalizers");
+ }
+ if (st_lookup(finalizer_table, obj, &table)) {
+ st_insert(finalizer_table, dest, table);
+ }
+}
+
static VALUE
run_single_final(args)
VALUE *args;