mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1e28976763
commit
576e131a48
2 changed files with 19 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Aug 29 19:10:10 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* hash.c (rb_hash_s_create): fixed memory leak, based on the patch
|
||||
by Kent Sibilev <ksruby at gmail.com>. fixed: [ruby-talk:211233]
|
||||
|
||||
Mon Aug 28 11:36:02 2006 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rdoc/parsers/parse_rb.rb: Fix typo. Submitted by
|
||||
|
|
19
hash.c
19
hash.c
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue