diff --git a/src/base/core.h b/src/base/core.h index a970388..51d36e8 100644 --- a/src/base/core.h +++ b/src/base/core.h @@ -423,7 +423,7 @@ static INLINE void allocator_free_all(Allocator *allocator) */ /** - * Initialize a list + * Initialize a list, can also just be zero initialized * * @param list struct pointer with a *first and a **last member to an entry struct */ @@ -484,7 +484,7 @@ do { \ */ /** - * Initialize a list + * Initialize a list, can also just be zero initialized * * @param list struct pointer with a *first and a *last member to an entry struct */ diff --git a/src/base/lalloc.c b/src/base/lalloc.c index 724a4c3..e4b1742 100644 --- a/src/base/lalloc.c +++ b/src/base/lalloc.c @@ -47,7 +47,7 @@ static inline U32 lbh_offset(LAlloc *allocator, LBlockHeader *block) return NULL_BLOCK; } - return (U32)((uintptr_t)block - (uintptr_t)allocator->base); + return (U32)((UMM)block - (uintptr_t)allocator->base); } static void lmaybe_split_block(LAlloc *allocator, LBlockHeader *block, U32 size) @@ -98,7 +98,9 @@ static void lmerge_with_next(LAlloc *allocator, LBlockHeader *block) lblock_set_size(block, new_size); block->next = next->next; LBlockHeader *nextnext = lblock_from_offset(allocator, next->next); - if (nextnext) nextnext->prev = lbh_offset(allocator, block); + if (nextnext != NULL) { + nextnext->prev = lbh_offset(allocator, block); + } // note - caller have to adjust next_alloc on return } @@ -131,7 +133,7 @@ void *lalloc(LAlloc *allocator, U32 size) } size = AlignUp(size, BLOCK_ALIGNMENT); - LBlockHeader *start = allocator->next_alloc ? allocator->next_alloc : (LBlockHeader *)allocator->base; + LBlockHeader *start = allocator->next_alloc; LBlockHeader *curr = start; do {