diff mbox

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

Message ID CAO9iq9H=MuaV_Z04QRqyEgOuk59Y=i76AkCZtTVLqA9ax8Ei0g@mail.gmail.com
State New
Headers show

Commit Message

Janne Blomqvist July 3, 2011, 8:35 p.m. UTC
On Fri, Jul 1, 2011 at 21:31, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Is this better?


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

Comments

Thomas Koenig July 5, 2011, 6:18 p.m. UTC | #1
Hi Janne,


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

OK.

Übertrage Daten ...........................................
Revision 175880 übertragen.

Thanks for the review!

	Thomas
diff mbox

Patch

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);
 }