Revision: 2877 http://trac.macosforge.org/projects/ruby/changeset/2877 Author: lsansonetti@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);
participants (1)
-
source_changes@macosforge.org