| 
  | 
Message-ID: <04951524-9a8a-ece7-5fa3-4ea4addb61ac@mirbsd.de>
Date: Fri, 31 Oct 2025 15:36:17 +0100 (CET)
From: Thorsten Glaser <tg@...bsd.de>
To: 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>, 
    Thiago Macieira <thiago@...ieira.org>
Subject: Re: Re: realloci(): A realloc() variant that works in-place
(no need to Cc me)
On Fri, 31 Oct 2025, Laurent Bercot wrote:
> As usual, and this applies to realloci() too, the question is: what
> exact problem are you trying to solve?
Yes. This.
> > > How is that supposed to work if you want to grow the
> > > allocation?
> > >
> > > This seems like increasing burden on the implementation
> > > for everyone, just for niche corner use cases.
> >
> > realloc(3) already does this sometimes.  If the memory has some empty
> In most cases, it will be very difficult for an implementation to
> increase the size of an allocated block without relocating the block.
> So you can expect realloci() to fail often. What should users do in
> that case?
Exactly. This makes me doubt its usefulness as a generic function.
Even were you to limit its use to shrinking allocations only, that
would constrain implementations, e.g. those that spread the allocations
based on their size and thus could not free anything.
So, in short:
When called with a larger size, it’ll just fail most of the time.
When called with a smaller size, it’ll just be a no-op in many cases.
bye,
//mirabilos
-- 
22:20⎜<asarch> The crazy that persists in his craziness becomes a master
22:21⎜<asarch> And the distance between the craziness and geniality is
only measured by the success 18:35⎜<asarch> "Psychotics are consistently
inconsistent. The essence of sanity is to be inconsistently inconsistent
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.