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 | 99bed88c85e15704f6b9015133ce33d03b7fa061 (patch) | |
tree | ea4c2ecb40a453671d382213e21558080202a8ce | |
parent | 5d7609be1b07034b5a36a67bcbd19860b93c69f6 (diff) | |
download | ruby-99bed88c85e15704f6b9015133ce33d03b7fa061.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | hash.c | 19 |
2 files changed, 19 insertions, 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:29:46 2006 Eric Hodel <drbrain@segment7.net> * eval.c, parse.y: Revert. @@ -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) |