🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4498

Re: Should free() take a pointer to const argument?

#4498
From: Lawrence Kirby
Date: Sun, 17 Dec 1995 17:53
43 lines
2839 bytes
In article <4arvsd$h1l@rdsunx.crd.ge.com>
           volpe@ausable.crd.ge.com "Christopher R. Volpe" writes:

>You're right. You can't detect change. YOu can sometimes detect lack of
>change, though.

I assume the argument would them proceed that if you determine that
representation pattern of the pointer returned from realloc is the same as
the one passed to it, then all pointers to the original object remain valid
as pointers to the new (or if you like altered) one. I'm not sure that this
is true since I don't see anything preventing an implementation scanning
a program's variables and clearing pointers to the original object (or
even just a selection of the pointers) when one is passed to free
or realloc. If you check on an individual basis whether each pointer
has the same bit pattern as that returned by realloc then you have the
situation where the value of the pointer is effectively derived (given
maning in this case) from the return value of realloc rather than as a
pointer to the original object. The whole area is rather murky and my
suggestion of redefining realloc in terms of destroying one object and
creating another would certainly make things a lot clearer and
interpretation much easier (and IMHO more consistent).

However I'd prefer to stick to the main thrust of why I started this
thread and that is (most important first):

1) Should the argument to free be const void *, and as a secondary
   consideration should it be const volatile void *.

2) Should the first argument of realloc be const void *
   (or const volatile void * if that is accepted for 1)?

3) Should the description of realloc be changed so that it is in terms of
   destroying one object and creating a new one. IMHO this would make
   it more consistent with the meaning and use of 'object' in the rest of the
   standard, does not ascribe strange properties to 'object' that exist
   nowhere else in the standard, and may also be required for consistency
   with point 2.

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID: <819222809snz@genesis.demon.co.uk>
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.uk
References: <818626119snz@genesis.demon.co.uk> <4am3dn$6s9@natasha.rmii.com> <818898225snz@genesis.demon.co.uk> <4apkl2$8sp@rdsunx.crd.ge.com> <4apn8t$bs8@newshost.lanl.gov> <4arvsd$h1l@rdsunx.crd.ge.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.uk
From: Lawrence Kirby <fred@genesis.demon.co.uk>
Newsgroups: comp.std.c
Subject: Re: Should free() take a pointer to const argument?
Date: Sun, 17 Dec 95 17:53:29 GMT
Organization: none
Distribution: world
Message-ID: <819222809snz@genesis.demon.co.uk>
References: <818626119snz@genesis.demon.co.uk> <4am3dn$6s9@natasha.rmii.com> <818898225snz@genesis.demon.co.uk> <4apkl2$8sp@rdsunx.crd.ge.com> <4apn8t$bs8@newshost.lanl.gov> <4arvsd$h1l@rdsunx.crd.ge.com>
Reply-To: fred@genesis.demon.co.uk
X-NNTP-Posting-Host: genesis.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.27