🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4473

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

#4473
From: Tanmoy Bhattacharya
Date: Thu, 14 Dec 1995 17:35
35 lines
2078 bytes
In article <4apkl2$8sp@rdsunx.crd.ge.com>, volpe@bart.crd.ge.com (Christopher
R. Volpe) writes: 
|> In article <818898225snz@genesis.demon.co.uk>, Lawrence Kirby
<fred@genesis.demon.co.uk> writes: 
<snip>
|> |>objects are viewed as distinct. Even if the realloc call returns the
same 
|> |>address as the one passed to it no strictly conforming program can rely
on 
|> |>this fact or even detect it since all pointers to the original object
are 
|>                ^^^^^^^^^^^^^^
|> 
|> You can detect it. Before calling realloc, look at the pointer value as an
|> array of (sizeof(void *)) bytes, and save those bytes somewhere. Then
compare 
|> bytes after the realloc. You're not evaluating the pointer, just inspecting
|> byte values.

But even if the byte values change, does it mean that realloc has moved the
stuff? There may be holes which change: or two different byte values may
correspond to the same pointer for other reasons.

Of course, if the byte values are identical, any reasonable interpretation of
the standard will say that the pointer is unchanged.

Cheers
Tanmoy
-- 
tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
<http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID: <4apn8t$bs8@newshost.lanl.gov>
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy
References: <818626119snz@genesis.demon.co.uk> <4am3dn$6s9@natasha.rmii.com> <818898225snz@genesis.demon.co.uk> <4apkl2$8sp@rdsunx.crd.ge.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy
From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
Newsgroups: comp.std.c
Subject: Re: Should free() take a pointer to const argument?
Date: 14 Dec 1995 17:35:25 GMT
Organization: Los Alamos National Laboratory
Distribution: world
Message-ID: <4apn8t$bs8@newshost.lanl.gov>
References: <818626119snz@genesis.demon.co.uk> <4am3dn$6s9@natasha.rmii.com> <818898225snz@genesis.demon.co.uk> <4apkl2$8sp@rdsunx.crd.ge.com>
NNTP-Posting-Host: qcd.lanl.gov