> > And get clarified the qsort/bsearch cases whether it is about just
> > nmemb == 0 or nmemb * size == 0.
> 
> C does not support zero-sized objects, so that's something for us to
> figure out on our own.  We can treat size == 0 as invalid because the
> functions can't work, as they use pointers for the comparison function
> and not array indices.

Hi Florian,

This is not really true.  ISO C claims to not support 0-sized objects,
but then allows malloc(0) to return non-null, and

        memcpy(malloc(0), malloc(0), 0);

has always been fully-complying in platforms like glibc, where malloc(0)
returns non-NULL.

Have a lovely day!
Alex


-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature

Reply via email to