[macruby-changes] [2877] MacRuby/trunk/re.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 21 14:23:19 PDT 2009


Revision: 2877
          http://trac.macosforge.org/projects/ruby/changeset/2877
Author:   lsansonetti at apple.com
Date:     2009-10-21 14:23:16 -0700 (Wed, 21 Oct 2009)
Log Message:
-----------
do not leak Match objects

Modified Paths:
--------------
    MacRuby/trunk/re.c

Modified: MacRuby/trunk/re.c
===================================================================
--- MacRuby/trunk/re.c	2009-10-21 20:47:01 UTC (rev 2876)
+++ MacRuby/trunk/re.c	2009-10-21 21:23:16 UTC (rev 2877)
@@ -845,6 +845,17 @@
     return (VALUE)match;
 }
 
+static IMP rb_objc_match_finalize_super = NULL; 
+
+static void
+rb_objc_match_finalize(void *rcv, SEL sel)
+{
+    onig_region_free(RMATCH_REGS(rcv), 0);
+    if (rb_objc_match_finalize_super != NULL) {
+	((void(*)(void *, SEL))rb_objc_match_finalize_super)(rcv, sel);
+    }
+}
+
 typedef struct {
     int byte_pos;
     int char_pos;
@@ -3745,6 +3756,9 @@
     rb_objc_define_method(*(VALUE *)rb_cMatch, "alloc", match_alloc, 0);
     rb_undef_method(CLASS_OF(rb_cMatch), "new");
 
+    rb_objc_match_finalize_super = rb_objc_install_method2((Class)rb_cMatch,
+	    "finalize", (IMP)rb_objc_match_finalize);
+
     rb_objc_define_method(rb_cMatch, "initialize_copy", match_init_copy, 1);
     rb_objc_define_method(rb_cMatch, "regexp", match_regexp, 0);
     rb_objc_define_method(rb_cMatch, "names", match_names, 0);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091021/058f0622/attachment.html>


More information about the macruby-changes mailing list