Hi Paul, On Sat, Oct 19, 2024 at 11:24:08AM GMT, Paul Eggert wrote: > On 2024-10-19 09:14, Alejandro Colomar wrote: ... > > On Sat, Oct 19, 2024 at 10:25:52AM GMT, Bruno Haible wrote: ... > > > What I would therefore suggest — if we want to change Gnulib at all > > > regarding realloc — is to make > > > realloc (ptr, 0) with ptr != NULL > > > abort. > > > > That would be bad. Programs that _need_ realloc(p,0) to work will have > > to workaround it by rolling their own realloc() wrapper, which will most > > likely contain bugs. > > Perhaps some package maintainers will prefer Bruno's suggestion, while some > will prefer realloc(p,0) to have the traditional/BSD semantics you're > proposing. So we could have two new Gnulib modules, say realloc-ptr-0-abort > for Bruno's suggestion, and realloc-ptr-0-nonnull for the traditional/BSD > semantics. > > I can work on developing realloc-ptr-0-nonnull and using it in some of the > packages I help maintain. That would help us move forward. I hope a > realloc-ptr-0-abort module isn't needed except perhaps briefly for > debugging. > > If the tunable is added to glibc as Siddhesh is proposing, I suppose the > realloc-gnu module should be changed to behave more like > realloc-ptr-0-nonnull, as it's more convenient for package maintainers to > assume the realloc-ptr-0-nonnull behavior than to write code that can work > with either current or future (or ancient :-) glibc behavior.
That sounds like a great plan. Thanks! :-) Please keep me updated about it. Have a lovely night! Alex -- <https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature