[svn:parrot] r49403 - trunk/src/gc

plobsing at svn.parrot.org plobsing at svn.parrot.org
Fri Oct 1 22:35:53 UTC 2010


Author: plobsing
Date: Fri Oct  1 22:35:52 2010
New Revision: 49403
URL: https://trac.parrot.org/parrot/changeset/49403

Log:
malloc can return null

Modified:
   trunk/src/gc/alloc_memory.c
   trunk/src/gc/gc_inf.c
   trunk/src/gc/gc_ms.c
   trunk/src/gc/gc_ms2.c

Modified: trunk/src/gc/alloc_memory.c
==============================================================================
--- trunk/src/gc/alloc_memory.c	Fri Oct  1 22:34:11 2010	(r49402)
+++ trunk/src/gc/alloc_memory.c	Fri Oct  1 22:35:52 2010	(r49403)
@@ -48,7 +48,7 @@
 
 PARROT_EXPORT
 PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
+PARROT_CAN_RETURN_NULL
 void *
 mem_sys_allocate(size_t size)
 {
@@ -57,7 +57,7 @@
 #ifdef DETAIL_MEMORY_DEBUG
     fprintf(stderr, "Allocated %i at %p\n", size, ptr);
 #endif
-    if (!ptr)
+    if (!ptr && size)
         PANIC_OUT_OF_MEM(size);
     return ptr;
 }
@@ -139,7 +139,7 @@
 
 PARROT_EXPORT
 PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
+PARROT_CAN_RETURN_NULL
 void *
 mem_sys_realloc_zeroed(ARGFREE(void *from), size_t size, size_t old_size)
 {
@@ -152,7 +152,7 @@
 #ifdef DETAIL_MEMORY_DEBUG
     fprintf(stderr, "Allocated %i at %p\n", size, ptr);
 #endif
-    if (!ptr)
+    if (!ptr && size)
         PANIC_OUT_OF_MEM(size);
 
     if (size > old_size)

Modified: trunk/src/gc/gc_inf.c
==============================================================================
--- trunk/src/gc/gc_inf.c	Fri Oct  1 22:34:11 2010	(r49402)
+++ trunk/src/gc/gc_inf.c	Fri Oct  1 22:35:52 2010	(r49403)
@@ -509,7 +509,7 @@
 */
 
 PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
+PARROT_CAN_RETURN_NULL
 static void *
 gc_inf_allocate_memory_chunk(SHIM_INTERP, size_t size)
 {
@@ -518,7 +518,7 @@
 #ifdef DETAIL_MEMORY_DEBUG
     fprintf(stderr, "Allocated %i at %p\n", size, ptr);
 #endif
-    if (!ptr)
+    if (!ptr && size)
         PANIC_OUT_OF_MEM(size);
     return ptr;
 }

Modified: trunk/src/gc/gc_ms.c
==============================================================================
--- trunk/src/gc/gc_ms.c	Fri Oct  1 22:34:11 2010	(r49402)
+++ trunk/src/gc/gc_ms.c	Fri Oct  1 22:35:52 2010	(r49403)
@@ -1336,7 +1336,7 @@
 */
 
 PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
+PARROT_CAN_RETURN_NULL
 static void *
 gc_ms_allocate_memory_chunk(SHIM_INTERP, size_t size)
 {
@@ -1345,7 +1345,7 @@
 #ifdef DETAIL_MEMORY_DEBUG
     fprintf(stderr, "Allocated %i at %p\n", size, ptr);
 #endif
-    if (!ptr)
+    if (!ptr && size)
         PANIC_OUT_OF_MEM(size);
     return ptr;
 }

Modified: trunk/src/gc/gc_ms2.c
==============================================================================
--- trunk/src/gc/gc_ms2.c	Fri Oct  1 22:34:11 2010	(r49402)
+++ trunk/src/gc/gc_ms2.c	Fri Oct  1 22:35:52 2010	(r49403)
@@ -1251,7 +1251,7 @@
 */
 
 PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
+PARROT_CAN_RETURN_NULL
 static void *
 gc_ms2_allocate_memory_chunk(SHIM_INTERP, size_t size)
 {
@@ -1260,7 +1260,7 @@
 #ifdef DETAIL_MEMORY_DEBUG
     fprintf(stderr, "Allocated %i at %p\n", size, ptr);
 #endif
-    if (!ptr)
+    if (!ptr && size)
         PANIC_OUT_OF_MEM(size);
     return ptr;
 }


More information about the parrot-commits mailing list