[patch, fortran] Always return malloc(1) for empty arrays in the library

Janne Blomqvist blomqvist.janne@gmail.com
Sun Jul 3 20:36:00 GMT 2011


On Fri, Jul 1, 2011 at 21:31, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Is this better?

Index: runtime/memory.c
===================================================================
--- runtime/memory.c	(Revision 175598)
+++ runtime/memory.c	(Arbeitskopie)
@@ -54,8 +54,8 @@ get_mem (size_t n)
 void *
 internal_malloc_size (size_t size)
 {
-  if (size == 0)
-    return NULL;
+  if (unlikely (size <= 0))
+    size = 1;

   return get_mem (size);
 }

Since size_t is unsigned, just test (size == 0).  Otherwise Ok. Thanks
for the patch.




-- 
Janne Blomqvist



More information about the Gcc-patches mailing list