Path: csiph.com!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: The return value of realloc(p,0)
Date: Fri, 01 Sep 2023 11:55:25 -0700
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <86fs3xsoyq.fsf@linuxsc.com>
References: <86edjju668.fsf@linuxsc.com> <86wmxas6ty.fsf@linuxsc.com> <20230901095453.20@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="e13a49a448cc252f76540c1a5198a3b9"; logging-data="4175704"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/PimG4WLYpJPUkt7FmAG5eL4NAVneYsRA="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:+P6KHiFINnu/zLvc9/O3LZI0ipE= sha1:SYI/Chc11ybKVh8mrBe2mWrv4pQ=
Xref: csiph.com comp.lang.c:173551
Kaz Kylheku <864-117-4973@kylheku.com> writes:
> On 2023-09-01, Tim Rentsch wrote:
>
>> What I meant was just over one bit /per zero-byte block/. So if
>> there were 20,000 zero-byte blocks, they could be managed with
>> just a little more than 2500 bytes of allocated memory. Sorry
>> for the confusion.
>
> The following is a much better requirement for malloc and realloc:
>
> In the zero size case, return a non-null pointer to a single
> program-wide object (always the same one), which can be passed
> to the free function any number of times. [...]
This idea is worse in one important respect: it doesn't satisfy
the specification in the C standard.
Incidentally, it also doesn't satisfy the requirements of the
people who proposed the idea to begin with.