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 10:27:22PM +0100, Kamil Rytarowski wrote:
> In C this is legal, but implementation defined. GNU C afair assumes malloc(1).

No, it doesn't. The only reason why many malloc implementations round up
is a lot of legacy software with broken error checks. Xorg being a very
well known example.

> For a safe function I propose to trigger ENOTSUP.

That's just bad as creates a needless set of complications for
functions. Consider a function that pops elements of the end of a
dynamic array. With your proposal, you can't just resize the array at
the end of a loop without having to check for emptiness before.

Joerg


Home | Main Index | Thread Index | Old Index