Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <792d17d3-7d75-4704-8d85-336e02231ebe@cs.ucla.edu>
Date: Fri, 31 Oct 2025 14:18:10 -0600
From: Paul Eggert <eggert@...ucla.edu>
To: Thiago Macieira <thiago@...ieira.org>, Alejandro Colomar <alx@...nel.org>
Cc: libc-alpha@...rceware.org, musl@...ts.openwall.com,
 "A. Wilcox" <AWilcox@...cox-tech.com>,
 Lénárd Szolnoki <cpp@...ardszolnoki.com>,
 Collin Funk <collin.funk1@...il.com>,
 Arthur O'Dwyer <arthur.j.odwyer@...il.com>,
 Jonathan Wakely <jwakely@...hat.com>, "Paul E. McKenney"
 <paulmck@...nel.org>, Oliver Hunt <oliver@...le.com>
Subject: Re: Re: realloci(): A realloc() variant that works in-place

On 10/31/25 11:53, Thiago Macieira wrote:

> The temptation is too great to cast the old to a T* and dereference it

That temptation exists no matter which of these APIs is used. It exists 
even with C89 malloc/realloc/free. The temptation won't be affected by 
changing the C standard now to better reflect how implementations behave.

> I wouldn't trust this feature to more 
> than a few dozen people on the planet.

I think it's more than that. But whatever the number, it's the same 
audience as the people who'd use a realloci API, or a 
realloc-unmmoved-or-malloc API. All these APIs are non-obvious and 
suitable for experts only.

The 7th Edition Unix API has significant advantages:

(1) No changes are needed to existing mainline implementations.

(2) For the use cases shown so far, it's more efficient than the other 
alternatives given.

(3) It matches naive C programmer expectations: lots of code already 
assumes the API, even though the code doesn't conform to the standard.

If it's too much of a stretch for the committee to require the 
traditional behavior, they could add a new macro (__STDC_REALLOC_REUSE__ 
say) which would guarantee the behavior. Implementations could then use 
efficient code if __STDC_REALLOC_REUSE__ is defined, and 
slower-but-portable-to-weird-platforms code otherwise.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.