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

login
register
mail settings
Submitter Janne Blomqvist
Date July 3, 2011, 8:35 p.m.
Message ID <CAO9iq9H=MuaV_Z04QRqyEgOuk59Y=i76AkCZtTVLqA9ax8Ei0g@mail.gmail.com>
Download mbox | patch
Permalink /patch/103035/
State New
Headers show

Comments

Janne Blomqvist - July 3, 2011, 8:35 p.m.
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.
Thomas Koenig - July 5, 2011, 6:18 p.m.
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

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