-
Notifications
You must be signed in to change notification settings - Fork 0
Added TLSF Allocator for dyamic heap allocation #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
f112f5e
to
12b07c4
Compare
12b07c4
to
a2012c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonably bulletproof - local run was fine. Just the few comments is all, but good to merge.
/** | ||
* A shorthand macro for making deallocations easier to manage. | ||
*/ | ||
#define FREE(ptr) Deallocate((void**) &ptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming should be a bit more explicit for the global namespace
* @param header the current header | ||
* @return true if the previous block is free, otherwise false | ||
*/ | ||
bool PrevBlockIsFree(BlockHeader* header); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functions missing const-correctness
* bytes | ||
* @return a pointer to the memory block | ||
*/ | ||
void* Allocate(const T& size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if this is compatible with stl allocation conventions
BlockHeader* GetHeader(FreeBlockNode* node); | ||
|
||
/** | ||
* @brief Returns the header of a data pointer. Assumes that the data is pointing to the start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brief
can be dropped
void* TlsfAllocator<T>::Allocate(const T& size) | ||
{ | ||
T requiredSize = sizeof(BlockHeader) + size + sizeof(BlockFooter); | ||
if (!data || capacity == 0 || size == 0 || requiredSize < size || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be helpful to spit out an error in each of these cases with more info
Description
...
The PR has been...
The code has been...
master
(according to GitHub)package
targets