Re: free()'ing restrict'ed pointers
- From: comeau@xxxxxxxxx (Greg Comeau)
- Date: 31 Jul 2008 14:51:07 -0400
In article <g6sg41$tlr$1@xxxxxxxxxxxxxxxxxxxxxxxxx>,
santosh <santosh.k83@xxxxxxxxx> wrote:
s0suk3@xxxxxxxxx wrote:
A object to which there is a pointer that has been declared 'restrict'
is supposed to be accessed only through that pointer. So is it safe to
call free() with a restricted pointer?
Yes.
Does free() try to access what
in points to in some way?
It most certainly accesses it's argument, but whether it accesses the
storage pointed to is not specified. In any case after calling free the
pointer object is left in an indeterminate state, and the storage
pointed at is no longer available. So it shouldn't matter to you
whether free accesses the storage or not.
It's worth pointing out that the restrict'ed point was originally
re/c/m/alloc()d and "handed over" to the restricted pointer.
But that of course does not make the memory restricted,
just through the restricted pointer it is treated as such.
So if you will, it can be "renomalized" back to being non-restricted
by being rehanded over again, in this case to free.
--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
.
- Follow-Ups:
- Re: free()'ing restrict'ed pointers
- From: Greg Comeau
- Re: free()'ing restrict'ed pointers
- References:
- free()'ing restrict'ed pointers
- From: s0suk3
- Re: free()'ing restrict'ed pointers
- From: santosh
- free()'ing restrict'ed pointers
- Prev by Date: Re: Weird malloc behaviour
- Next by Date: Re: diagnostic message
- Previous by thread: Re: free()'ing restrict'ed pointers
- Next by thread: Re: free()'ing restrict'ed pointers
- Index(es):
Relevant Pages
|