Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
To: NetBSD Toolchain Technical Discussion List <tech-toolchain@NetBSD.ORG>
From: David Laight <david@l8s.co.uk>
List: tech-toolchain
Date: 07/14/2003 22:14:21
> But the point remains -- you said you tried adding the the 'const'
> qualifier to the function parameter in question and then you said you
> would end up having "to do free(DECONST(pointer))".  Something,
> somewhere, is very wrong.  (but you've now given me the hint below to
> show what's wrong -- yes, I should have read the code first, but I
> didn't)

But it happens all the time with sequences like:
1) allocate a chunk of memory
2) fill it
3) put the address into a structure for an write/display asynchronous routine
4) call the routine
... sometime later...
5) notification that asynchronous action is complete
6) try to free the memory

Unless you saved the pointer somewhere else, you only have its address
in a 'const' pointer.

Because data areas can become const (ie are not changed once they have
been initialised) you need to be able to call free() with a const pointer.


	David

-- 
David Laight: david@l8s.co.uk