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