tech-userlevel archive

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

Re: Reuse strtonum(3) and reallocarray(3) from OpenBSD



On Tue, Nov 25, 2014 at 12:22:10AM +0100, Kamil Rytarowski wrote:
> OpenBSD standardized in its eco-system i.e. two functions:
> - reallocarray(3) is a safer drop-in replacement of realloc(3)
> - strtonum(3) is yet another function to change literal string to a number

As with strtonum, reallocarray has enough problems of its own. While it
fixes the problem of overflows, it doesn't handle the problem of failing
allocations gracefully. If you don't want to make that fatal or leak
memory, you still have to use a separate variable. Another issue is that
the API as it is doesn't properly deal with zero sized allocations. In
short, this API is once again not nearly as useful as it could be and
not something I want to see in libc...

Joerg


Home | Main Index | Thread Index | Old Index