diff options
-rw-r--r-- | magic_buddy.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/magic_buddy.c b/magic_buddy.c index 1e88c21..868bfd7 100644 --- a/magic_buddy.c +++ b/magic_buddy.c @@ -86,7 +86,7 @@ static void *_allocate(size_t logsize, struct buddy *state) { return parent; } void *allocate(size_t size, struct buddy *state) { - size = (size < sizeof(struct free_block)) ? sizeof(struct free_block) : size; + if (size < sizeof(struct free_block)) size = sizeof(struct free_block); return _allocate(size2log(size, 1), state); } @@ -201,6 +201,8 @@ void *reallocate(void *old, size_t old_size, size_t new_size, struct buddy *state) { if (new_size == 0) return liberate(old, old_size, state), (void*)0; + if (size < sizeof(struct free_block)) size = sizeof(struct free_block); + size_t old_logsize = size2log(old_size, 1); size_t new_logsize = size2log(new_size, 1); |