1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2009-09-17 09:34:20 +00:00
parent c8c6fde56f
commit 0cb17717fe
2 changed files with 10 additions and 1 deletions

View file

@ -1,3 +1,7 @@
Thu Sep 17 18:34:19 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (vm_xrealloc): free as like standard free if size is zero.
Thu Sep 17 15:41:02 2009 Koichi Sasada <ko1@atdot.net>
* eval_intern.h: use rb_node_newnode() directly.

7
gc.c
View file

@ -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);