Re: free()'ing restrict'ed pointers



s0suk3@xxxxxxxxx wrote:

Hi,

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.

.



Relevant Pages

  • Re: restrict in plain English?
    ... it's impossible to swap a restrict pointer with another pointer, ... compiler might generate this code itself, ... The restrict qualifier only has meaning in terms of modifying an ...
    (comp.lang.c)
  • Re: Using restricted pointers with newly allocated arrays/structures
    ... return (int) x; ... might return the same pointer. ... yet the initialization of that object to 0.0 in ... Restrict qualification becomes interesting only when there is* ...
    (comp.std.c)
  • Re: Useless obfucation in synopsis for fopen
    ... the const qualifiers do precisely that. ... pointer parameter to make sure it is safe to pass a pointer to constant; ... Having read this thread and "General remarks on restrict", ... restrict is a contract from the caller to the callee. ...
    (comp.std.c)
  • Re: Restricted pointer parameters in printf()
    ... >> The restrict keyword is completely unnecessary and has no effect on ... void some_func(int *a, int *b, int count) ... calls were made with a pointer to an int having the value 2. ...
    (comp.lang.c)
  • Re: Restricted pointer parameters in printf()
    ... then accesses to the object must go through that parameter. ... >>is illegal if the string literals are coalesced into the same pointer? ... but I thought that the restrict keyword was ...
    (comp.lang.c)