Wednesday, January 4, 2012

Aligned Allocator Bug

From: Dave Asbell

Hey Jason,
I am reading your book and I think there is a bug in the aligned allocator. Shouldn't the code be casting the alignedAddress to a U8 instead of a U32 and subtracting 1 byte instead of 4? I believe this would write the offset into the byte preceding the aligned address instead of the word.  Similarly shouldn't the free routine be using a 1 byte offset as well? Perhaps I am missing something. In any event I love the book and look forward to finishing it.

_________________________________________

You are quite right; the code was written originally with 4-byte offsets, but I changed it (very sloppily!) to use 1-byte offsets without double-checking it.  It's one of the errata I plan to post on the book's site when I get some free time.

Glad you're enjoying it!  Do send along any other errata you notice.

Cheers,
J

No comments:

Post a Comment