summaryrefslogtreecommitdiff
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
commita526e3fe0251880978baee867f72d59de4b3e84e (patch)
treef47e9ce8f0c67d0fde2a89046f60ebd0afc5d3dc /gc.c
parent96f82b243fce324b33e71357564a15b51f6aa949 (diff)
* object.c (copy_object): copy finalizers as well if any.
* gc.c (rb_gc_copy_finalizer): new function to copy finalizers. git-svn-id: svn+ssh://ci.ruby-lang.org/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 3f8c4f97be..f925e55e0c 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;