I'm going to try to clean up the stuff valgrind is complaining about.
The leakage stuff will take a little time, it looks like, so I'm going
for the low-hanging fruit first. As XEmacs runs, valgrind complains
bitterly about lots and lots of cases where we essentially memcpy(&x,
&x, sizeof(x)). Since memcpy() is only guaranteed to work on
nonoverlapping addresses, a conforming memcpy implementation *could*
scramble the bytes of x. It turns out these memcpy()s are gcc's
doing. For structs x and y, "x = y;" gets turned into a memcpy call,
without first checking that &x != &y. That should probably be
considered a gcc bug, but on the other hand, there's no need for us to
do "x = x;" either.
So here's the first case I hit. In event-Xt.c, function
emacs_Xt_event_handler, line 1460 says:
x_event_copy = &EVENT_MAGIC_X_EVENT (emacs_event);
which the preprocessor expands to:
x_event_copy = &((emacs_event)->event.magic.underlying.x_event);
Next a bunch of stuff happens in a switch statement, followed on line 1496 by:
SET_EVENT_MAGIC_X_EVENT (emacs_event, *x_event_copy);
which the preprocessor expands to:
do { (emacs_event)->event.magic.underlying.x_event = (*x_event_copy);
} while (0);
There is no code in between that changes the value of the pointers
emacs_event or x_event_copy, so this amounts to:
x = &y;
y = *x;
As far as I can see, the SET_EVENT_MAGIC_X_EVENT call is a no-op. I'd
like to remove it. Any objections?
--
Jerry James
http://loganjerry.googlepages.com/
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta