On Wed, Jun 29, 2011 at 00:50, Thomas Koenig <tkoe...@netcologne.de> wrote:
> Hello world,
>
> looking at PR 49479 and other functions in the library made me realize
> there are lots of places where we don't malloc one byte for empty
> arrays.

I'd prefer to add the zero check to runtime/memory.c
(internal_malloc_size), i.e. change

if (size == 0)
  return NULL;

to

if (size == 0)
  size = 1;

Or perhaps even better would be to add that check to get_mem() instead
(as a side effect making internal_malloc_size redundant), thus
matching how memory allocation works in the frontend? Looking at
get_mem() we actually have a small bug here; if size == 0 and malloc
happens to return NULL we treat it as an error.

-- 
Janne Blomqvist

Reply via email to