diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-04 20:05:42 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-04 20:05:42 +0000 |
commit | 03f7f9ea40d6da40d847d6a422c66ff229bd2aa9 (patch) | |
tree | 94ecc16efc254e9495ba69052681c8cbe05c5b26 /gc.c | |
parent | db58af6051886ba44e6e741210dc4c242c62dd0f (diff) |
* 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
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -3529,7 +3529,14 @@ vm_xrealloc(rb_objspace_t *objspace, void *ptr, size_t size) if ((ssize_t)size < 0) { negative_size_allocation_error("negative re-allocation 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) { vm_xfree(objspace, ptr); return 0; |