emmalloc: set errno on error paths
emmalloc functions were returning NULL on error, but didn't set errno.
Errno is not DCEable, requires an awkward TLS slot that user might not have asked for, and very rarely used in web space. (in the close to decade of emmalloc, nobody ever asked for errno support)
I think if something, we should make the alignment failures abort in development mode, rather than return 0. So that way if emmalloc return 0, one will know it was due to an OOM.
In -sABORTING_MALLOC builds, we could optimize out the return 0;s altogether. I.e. allocations will either return a valid pointer, or halt.
The main reason to use emmalloc instead of dlmalloc is to get smaller code size. So it would be best to optimize it for the smallest code size to keep that angle intact.
I think if something, we should make the alignment failures abort in development mode, rather than return 0. So that way if emmalloc return 0, one will know it was due to an OOM.
I agree, except for the posx_memalign usage. That should probably still set errno and return on bad alignment.
I think if something, we should make the alignment failures abort in development mode, rather than return 0. So that way if emmalloc return 0, one will know it was due to an OOM.
I agree, except for the
posx_memalignusage. That should probably still set errno and return on bad alignment.
In fact malloc itself can only ever fail with ENOMEM, according the man page. No other errors are possible.