gbowne1 version of implementation with more implementations done #4

Merged
Karutoh merged 4 commits from gbowne1_impl into main 2024-02-14 18:08:17 -08:00
Collaborator

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.

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.
gbowne1 added 1 commit 2024-02-14 00:30:43 -08:00
Owner

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.

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.
Owner

Seems an alignment of 16 bytes is indeed required of x64 architectures.

Seems an alignment of 16 bytes is indeed required of x64 architectures.
Owner

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.

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.
Owner

There's an additional ALIGN16 macro function call in fragment_block function which is unnecessary.

There's an additional `ALIGN16` macro function call in `fragment_block` function which is unnecessary.
Owner

In the find_best_fit function on line number 111. There's a null pointer error. In the statement if (!best_fit || current->size < best_fit->size) will still try the current->size < best_fit->size logic regardless, which best_fit can and will be NULL.

In the `find_best_fit` function on line number 111. There's a null pointer error. In the statement `if (!best_fit || current->size < best_fit->size)` will still try the `current->size < best_fit->size` logic regardless, which `best_fit` can and will be `NULL`.
Owner

In my_custom_free there's an error on line number 232 for the statement if (b == last). The last global 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.

In `my_custom_free` there's an error on line number 232 for the statement `if (b == last)`. The `last` global 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.
Karutoh self-assigned this 2024-02-14 15:41:21 -08:00
Karutoh requested review from Karutoh 2024-02-14 15:41:33 -08:00
Karutoh requested changes 2024-02-14 15:44:23 -08:00
Karutoh left a comment
Owner

This is not an error. The changes of struct block* b = (struct block*)ptr - 1; to struct 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.

This is not an error. The changes of `struct block* b = (struct block*)ptr - 1;` to `struct 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.
Karutoh removed their assignment 2024-02-14 15:44:57 -08:00
gbowne1 was assigned by Karutoh 2024-02-14 15:45:00 -08:00
gbowne1 added 1 commit 2024-02-14 16:23:22 -08:00
gbowne1 added 1 commit 2024-02-14 16:51:52 -08:00
Author
Collaborator

yey me
fixed it.

yey me fixed it.
gbowne1 added 1 commit 2024-02-14 16:55:43 -08:00
Karutoh merged commit f341253aa8 into main 2024-02-14 18:08:17 -08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Karutoh/CustomHeapManager#4
No description provided.