[前][次][番号順一覧][スレッド一覧]

ruby-changes:26645

From: kosaki <ko1@a...>
Date: Sat, 5 Jan 2013 05:05:52 +0900 (JST)
Subject: [ruby-changes:26645] kosaki:r38696 (trunk): * gc.c (vm_xrealloc): add a few comment why we avoid realloc(ptr,0).

kosaki	2013-01-05 05:05:42 +0900 (Sat, 05 Jan 2013)

  New Revision: 38696

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38696

  Log:
    * gc.c (vm_xrealloc): add a few comment why we avoid realloc(ptr,0).

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38695)
+++ ChangeLog	(revision 38696)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jan  5 05:04:39 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* 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@y...>
 
 	* Makefile.in (RBCONFIG): Moved from common.mk in order to use the
Index: gc.c
===================================================================
--- gc.c	(revision 38695)
+++ gc.c	(revision 38696)
@@ -3529,7 +3529,14 @@ vm_xrealloc(rb_objspace_t *objspace, voi https://github.com/ruby/ruby/blob/trunk/gc.c#L3529
     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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]