diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-29 10:11:27 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-29 10:11:27 +0000 |
| commit | c6c48ae01292966a75dbb15ebb7f4aa350af6dbb (patch) | |
| tree | 91edc73ba18230817bfca039a7e583ce9cc0bb35 /hash.c | |
| parent | 22545ac33a578661f872090bcf86d2e3e1776fcf (diff) | |
| download | ruby-c6c48ae01292966a75dbb15ebb7f4aa350af6dbb.tar.gz ruby-c6c48ae01292966a75dbb15ebb7f4aa350af6dbb.tar.xz ruby-c6c48ae01292966a75dbb15ebb7f4aa350af6dbb.zip | |
* hash.c (rb_hash_s_create): fixed memory leak, based on the patch
by Kent Sibilev <ksruby at gmail.com>. fixed: [ruby-talk:211233]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
| -rw-r--r-- | hash.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -223,20 +223,31 @@ rb_hash_foreach(hash, func, farg) rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash); } +static VALUE hash_alloc0 _((VALUE)); static VALUE hash_alloc _((VALUE)); static VALUE -hash_alloc(klass) +hash_alloc0(klass) VALUE klass; { NEWOBJ(hash, struct RHash); OBJSETUP(hash, klass, T_HASH); hash->ifnone = Qnil; - hash->tbl = st_init_table(&objhash); return (VALUE)hash; } +static VALUE +hash_alloc(klass) + VALUE klass; +{ + VALUE hash = hash_alloc0(klass); + + RHASH(hash)->tbl = st_init_table(&objhash); + + return hash; +} + VALUE rb_hash_new() { @@ -325,9 +336,7 @@ rb_hash_s_create(argc, argv, klass) int i; if (argc == 1 && TYPE(argv[0]) == T_HASH) { - hash = hash_alloc(klass); - - RHASH(hash)->ifnone = Qnil; + hash = hash_alloc0(klass); RHASH(hash)->tbl = st_copy(RHASH(argv[0])->tbl); return hash; |
