Created
July 27, 2026 16:34
-
-
Save theMackabu/cc170fc8b5e7095b2ef97eca98c12f8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static inline size_t max_size_n(const size_t *values, size_t count) { | |
| size_t max = values[0]; | |
| for (size_t i = 1; i < count; ++i) | |
| if (values[i] > max) max = values[i]; | |
| return max; | |
| } | |
| #define MAX_SIZE(...) \ | |
| max_size_n((const size_t[]){__VA_ARGS__}, \ | |
| sizeof((const size_t[]){__VA_ARGS__}) / sizeof(size_t)) \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://github.com/sharifsegfaults/nalloc/blob/7f023ccbb6f82245ab3a284382e7e018311d7d94/mm.c#L361-L364 | |
| size_t expansion_size = ALIGN(MAX_SIZE( | |
| (size_t)(EXPANSION_FACTOR * mem_heapsize()), | |
| sizeof(AllocBlockHeader) + size - recyclable_space, | |
| sizeof(FreeBlockHeader) + sizeof(BlockFooter) | |
| )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment