bug-gnulib
[Top][All Lists]
Advanced

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

Re: Does anybody use Gnulib's eealloc module?


From: Paul Eggert
Subject: Re: Does anybody use Gnulib's eealloc module?
Date: Tue, 5 Nov 2024 13:54:33 -0800
User-agent: Mozilla Thunderbird

On 2024-11-04 22:48, Bruno Haible wrote:
The modules amemxfrm, safestriconveh, string-buffer could be simplified
slightly by depending on realloc-posix and assuming the new
realloc-posix behavior.
I would say, it's not worth the dependency: a module dependency sometimes
adds complexity to the build infrastructure (see e.g. libintl for what
I mean), whereas an 'errno = ENOMEM;' assignment in a cold code branch
is practically zero-cost.

To my mind the main reason to use realloc-posix in these three modules is reliability, not efficiency. When S == 0 and sizeof *P == 1, a problem with (P = realloc (P, S?S:1)) is that static and/or dynamic checking won't catch a later source-code bug that incorrectly dereferences P.

Whether amemxfrm etc. benefit enough from this extra checking is of course a judgment call.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]