On Tue, 9 May 2000, Petr Sorfa wrote:
> current invlib.c@...:
> entryptr = (ENTRY *) (invcntl->logblk->invblk + 3) + invcntl->keypnt;
> previous version:
> entryptr = (ENTRY *) (invcntl->logblk + 12) + invcntl->keypnt;
> Did you actually rather mean to have:
> entryptr = (ENTRY *) (invcntl->logblk->invblk + 3*sizeof (long)) +
No. The trick is that 'invblk' is already a pointer to long, so to
increment it by 3 long's worth, I just have to add 3, not 3*sizeof(long),
or the original 12.
The heart of my modification is that 'invcntl->logblk' is no longer an
anonymous 'char *', but a pointer to the 'union logicalblk' defined by
invlib.c. This union has two elements: the 'long invblk', and
the 'char chrblk'.
So for all cases that required the original 'logblk' to be casted to (long
*), before being used, I now use the 'invblk' incarnation of that union,
while all cases originally using a (char *) now do their access through
'chrblk'. That method is not fundamentally safer than the original
pointer casts, of course, but it's a bit more expressive. Replacing the
marked occurences of 'magic numbers' by named constants or maybe
macro would help
The 'real' solution would have to work in a different way, using a clearer
representation of the datafile's content in-memory. But let's leave that
for next week, shall we?
Hans-Bernhard Broeker (broeker@...)
Even if all the snow were burnt, ashes would remain.