summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-17 09:34:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-17 09:34:20 +0000
commit0cb17717fe3ce324376255efb759fdf8f94e0929 (patch)
tree4e1529c6793fbe47803a62f1a7b0dcea7677cd6d /gc.c
parentc8c6fde56f84c4fd26ade4268376279c65266949 (diff)
* gc.c (vm_xrealloc): free as like standard free if size is zero.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index dc8916b885..6469e98b58 100644
--- a/gc.c
+++ b/gc.c
@@ -604,6 +604,8 @@ garbage_collect_with_gvl(rb_objspace_t *objspace)
}
}
+static void vm_xfree(rb_objspace_t *objspace, void *ptr);
+
static void *
vm_xmalloc(rb_objspace_t *objspace, size_t size)
{
@@ -652,7 +654,10 @@ vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t size)
negative_size_allocation_error("negative re-allocation size");
}
if (!ptr) return ruby_xmalloc(size);
- if (size == 0) size = 1;
+ if (size == 0) {
+ vm_xfree(objspace, ptr);
+ return 0;
+ }
if (ruby_gc_stress && !ruby_disable_gc_stress)
garbage_collect_with_gvl(objspace);