gbowne1 version of implementation with more implementations done #4
Reference in New Issue
Block a user
No description provided.
Delete Branch "gbowne1_impl"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Added a bunch of stuff to show you how I would do some of this. It might need some cleanup work but hope this helps.
Added better fragment handling
Fixed heap extension logic
Added some minor error handling - Needs more work
I aligned for 64 bit systems which I looked might use ALIGN16 in place of ALIGN4 or even 8. I wasnt sure if you wanted to target just 64 bit.
should be reasonably clean at this point.
some stuff to think about Havent had a lot of time in a couple days.
Ideally our target should be for both x86 and x64. Just for your operating system and embedded hardware. We want this to be a good example for both.
Seems an alignment of 16 bytes is indeed required of x64 architectures.
I noticed on line number 34 there's an issue. You've done
s += BLOCK_SIZE;. This not ideal and should only hold the size of data the memory block contains, not including the memory block header. Otherwise it will require an extra operation or more.There's an additional
ALIGN16macro function call infragment_blockfunction which is unnecessary.In the
find_best_fitfunction on line number 111. There's a null pointer error. In the statementif (!best_fit || current->size < best_fit->size)will still try thecurrent->size < best_fit->sizelogic regardless, whichbest_fitcan and will beNULL.In
my_custom_freethere's an error on line number 232 for the statementif (b == last). Thelastglobal variable was not updated prior to that statement, which in turn the statement will never be true and may point to stale data on the heap.This is not an error. The changes of
struct block* b = (struct block*)ptr - 1;tostruct block *b = (struct block *)((char *)ptr - BLOCK_SIZE);adds more text to parse for the compiler and the user. Both do the same thing.Please resolve the errors provided above.
yey me
fixed it.