graphics32 icon indicating copy to clipboard operation
graphics32 copied to clipboard

AlphaTable memory

Open tomwiel opened this issue 4 years ago • 1 comments

procedure GenAlphaTable; As far as I understand, the half size would suffice, because the last half is unused or is unplanned? to be used. New: GetMem(AlphaTable, 257 * 4 * SizeOf(Cardinal));

tomwiel avatar Apr 08 '22 17:04 tomwiel

That's a good question. At present I have no idea about what AlphaTable is used for but as far as I can tell the code at least needs the current size to be valid on 64-bit POSIX platforms where SizeOf(LongWord)=8. If that is the reason for the current size then the code could/should have been written in a different way so as to not waste space on other platforms. My guess is that

GetMem(AlphaTable, 257 * 8 * SizeOf(Cardinal));

should be

GetMem(AlphaTable, 257 * SizeOf(LongWord) * 4);

since the table is filled with 256*4 LongWord values in the loop. I'm assuming that the extra 32 bytes allocated is to make sure that the memory can be 16 byte aligned.

I can see from Git blame that the current size was introduced by @CWBudde together with a bunch of unrelated changes in commit 9c8a4582ed08258820774ce2b00f454f4ebde27e. Maybe he has an explanation?

andersmelander avatar Apr 08 '22 19:04 andersmelander