[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gEDA-dev: PCB MyFree
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
_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev