gEDA-dev: PCB MyFree
ldoolitt at recycle.lbl.gov
ldoolitt at recycle.lbl.gov
Mon Jun 19 15:10:51 EDT 2006
Friends -
I just started my migration from pcb-20040903 (!) to something
more modern. The first thing I check for is cleanliness of compile.
It gives me a good hint as to where possible troubles are, especially
running a 64-bit machine as I do. My environment is Debian sid amd64,
currently gcc 4.1.2 20060613 (prerelease).
The CVS copy of PCB looks pretty good, and in fact installs, runs and
seems to do useful stuff. On the compile-time warnings side, the
noisiest issue is the use of MyFree(). This arguably exposes a
deficiency in the C language, in that there is no such thing as
a pointer to (arbitrary pointer). "void **" is subtly different,
that is a pointer to (pointer to arbitrary data). Thus almost every
use of MyFree, like
MyFree ((char **) &layer->Polygon);
triggers a
warning: dereferencing type-punned pointer will break strict-aliasing rules
Changing the MyFree parameter to (void **) doesn't help.
The only reasonable solution I found is to
#define MYFREE(x) do { SaveFree(x); (x)=NULL; } while (0)
This requires replacing some 49 invocations of MyFree with the
new macro. The result looks cleaner to me in the source, is
closer in application to the C standard free(), and eliminates
all those strict-aliasing warnings. The example above becomes
MYFREE (layer->Polygon);
Comments? If I turned in a patch, would someone check it in?
- Larry
More information about the geda-dev
mailing list