mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* gc.c (vm_xrealloc): add a few comment why we avoid realloc(ptr,0).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
db58af6051
commit
03f7f9ea40
2 changed files with 11 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sat Jan 5 05:04:39 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* gc.c (vm_xrealloc): add a few comment why we avoid realloc(ptr,0).
|
||||||
|
|
||||||
Fri Jan 4 20:17:06 2013 Yuki Yugui Sonoda <yugui@yugui.jp>
|
Fri Jan 4 20:17:06 2013 Yuki Yugui Sonoda <yugui@yugui.jp>
|
||||||
|
|
||||||
* Makefile.in (RBCONFIG): Moved from common.mk in order to use the
|
* Makefile.in (RBCONFIG): Moved from common.mk in order to use the
|
||||||
|
|
7
gc.c
7
gc.c
|
@ -3529,7 +3529,14 @@ vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t size)
|
||||||
if ((ssize_t)size < 0) {
|
if ((ssize_t)size < 0) {
|
||||||
negative_size_allocation_error("negative re-allocation size");
|
negative_size_allocation_error("negative re-allocation size");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ptr) return vm_xmalloc(objspace, size);
|
if (!ptr) return vm_xmalloc(objspace, size);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The behavior of realloc(ptr, 0) is implementation defined.
|
||||||
|
* Therefore we don't use realloc(ptr, 0) for portability reason.
|
||||||
|
* see http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_400.htm
|
||||||
|
*/
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
vm_xfree(objspace, ptr);
|
vm_xfree(objspace, ptr);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue