tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: reallocarr(3)

On Thu, Feb 05, 2015 at 09:56:51PM +0100, Kamil Rytarowski wrote:
> Joerg Sonnenberger wrote:
> The main properties of reallocarray(3):
> + safe realloc(3) with overflow detection,
> + safe malloc(3) with overflow detection without initialization overhead of calloc(3)
> an article

+ supports memory leaks
+ doesn't deal properly with zero sized allocations

> reallocarr(3):
> + distinguish ENOMEM and EOVERFLOW
> + tries to preserve global errno
> ~ hacky way to manage foo** pointers, is it portable? is it safe?
> ~ no malloc(3) replacement without initialization overhead
> ~ not realloc(3) replacement, as passing NULL won't work

Both is possible, just set the pointer to NULL first and it does the
equivalent of malloc.


Home | Main Index | Thread Index | Old Index