summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-29 10:11:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-29 10:11:27 +0000
commit99bed88c85e15704f6b9015133ce33d03b7fa061 (patch)
treeea4c2ecb40a453671d382213e21558080202a8ce /hash.c
parent5d7609be1b07034b5a36a67bcbd19860b93c69f6 (diff)
* 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
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/hash.c b/hash.c
index 4afba8b624..7a3035f6df 100644
--- a/hash.c
+++ b/hash.c
@@ -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)