News for hackers. Stuff that matters.
Re:Once upon a time, memory allocators made sense by cperciva on Monday January 18, 2016 @02:36PM (#10926368)
erm... allocating zero was never a good idea. it had varying behaviours on varying platforms for as long as i could remember and was one of those special cases to avoid.

No, allocating zero bytes is a perfectly reasonable thing to do, as long as you remember that NULL is not necessarily an allocation failure.

    if (((buf = malloc(buflen)) == NULL) && (buflen > 0))
        goto OUTOFMEMORY;
is perfectly good code.
Re:Once upon a time, memory allocators made sense by jheriko on Thursday January 21, 2016 @06:21AM (#10944549)
thats not even close to reasoning imo, its just an assertion.

... but i agree that the code is safer if you check for bad cases.

i can't see why allocating zero ever is more sensible than not doing it at all (and therefore avoiding even having to know about this problem, much less deal with it).