pardo@june.cs.washington.edu (David Keppel) (04/29/89)
This is a `how do I do this in dpANS C' question.
I have a structure that contains pointers to other structures.
struct container_t {
struct adt_t *x;
struct other_stuff x;
};
I have defined some accessor functions, including an initialization
function. The init function takes a pointer to a struct adt_t and
squirrels it away in the struct container_t. The init function does not
change what the adt_t points at. Suppose that my initial attempt at
defining a prototype looks like
extern void
init (struct container_t *dest, struct adt_t squirrel);
Somebody else might get a handle on
the struct adt_t, and change it. Thus,
* `init' does not change the `struct adt_t'.
* `struct container_t' is never used directly to change the `struct
adt_t'.
* The `struct adt_t' may change from time to time.
I am wanting to make the following declaration:
"`init' does not change what it's parameter points at."
The struct container_t does not take a const pointer, so I can't declare
`squirrel' as a const-qualified parameter. I could change the struct
container_t to have a const pointer, but that is incorrect because the
pointed-to storage might change over the lifetime of the container_t.
How should I declare `init'?
Thanks!
;-D on ( A volatile topic ) Pardo
--
pardo@cs.washington.edu
{rutgers,cornell,ucsd,ubc-cs,tektronix}!uw-beaver!june!pardo