1
0
Fork 0
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/trunk@10796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2006-08-29 10:11:27 +00:00
parent 5d7609be1b
commit 99bed88c85
2 changed files with 19 additions and 5 deletions

View file

@ -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:29:46 2006 Eric Hodel <drbrain@segment7.net>
* eval.c, parse.y: Revert.

19
hash.c
View file

@ -197,17 +197,26 @@ rb_hash_foreach(VALUE hash, int (*func)(ANYARGS), VALUE farg)
}
static VALUE
hash_alloc(VALUE klass)
hash_alloc0(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(VALUE klass)
{
VALUE hash = hash_alloc0(klass);
RHASH(hash)->tbl = st_init_table(&objhash);
return hash;
}
VALUE
rb_hash_new(void)
{
@ -299,9 +308,7 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE 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;
@ -1644,6 +1651,7 @@ rb_env_path_tainted(void)
return path_tainted;
}
#if !defined(_WIN32) && !(defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
static int
envix(const char *nam)
{
@ -1664,6 +1672,7 @@ envix(const char *nam)
FREE_ENVIRON(environ);
return i;
}
#endif
void
ruby_setenv(const char *name, const char *value)