summaryrefslogtreecommitdiff
path: root/ext/strscan/strscan.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-16 12:56:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-16 12:56:48 +0000
commit6fb9349d85960858023eb9c16826b68408279175 (patch)
tree0ad55fedb988498028a4f7ded7ff773c2667cca4 /ext/strscan/strscan.c
parentcb54008be67547866fa7a552a3eff5059d34c1b3 (diff)
allocate structs with wrapper
* parse.y (rb_parser_new, ripper_s_allocate): allocate structs with making new wrapper objects and get rid of potential memory leak. * variable.c (rb_autoload): ditto. * ext/digest/digest.c (rb_digest_base_alloc): ditto. * ext/strscan/strscan.c (strscan_s_allocate): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/strscan/strscan.c')
-rw-r--r--ext/strscan/strscan.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index 55d13d4..a0a015b 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -198,12 +198,12 @@ static VALUE
strscan_s_allocate(VALUE klass)
{
struct strscanner *p;
+ VALUE obj = TypedData_Make_Struct(klass, struct strscanner, &strscanner_type, p);
- p = ZALLOC(struct strscanner);
CLEAR_MATCH_STATUS(p);
onig_region_init(&(p->regs));
p->str = Qnil;
- return TypedData_Wrap_Struct(klass, &strscanner_type, p);
+ return obj;
}
/*