Fix marena macros
This commit is contained in:
+8
-5
@@ -248,6 +248,9 @@ void miniarena_test1(void)
|
|||||||
Assert(arena.first_free == arena_size);
|
Assert(arena.first_free == arena_size);
|
||||||
MemoryZero(ptr, arena_size);
|
MemoryZero(ptr, arena_size);
|
||||||
marena_temp_end(&checkpoint);
|
marena_temp_end(&checkpoint);
|
||||||
|
U32 *val = marena_push_type(&arena, U32);
|
||||||
|
*val = 0xa0b0c0d0;
|
||||||
|
printf("marena val %u\n", *val);
|
||||||
|
|
||||||
printf("miniarena_test1,size %u bytes first_free %u\n", arena.size, arena.first_free);
|
printf("miniarena_test1,size %u bytes first_free %u\n", arena.size, arena.first_free);
|
||||||
|
|
||||||
@@ -359,13 +362,13 @@ void apool_test_autogrow(void)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// arena_test_1();
|
arena_test_1();
|
||||||
// arena_test_2();
|
arena_test_2();
|
||||||
// arena_test_3();
|
arena_test_3();
|
||||||
// arena_test_4();
|
arena_test_4();
|
||||||
arena_test_decommit();
|
arena_test_decommit();
|
||||||
arena_test_allocator_interface();
|
arena_test_allocator_interface();
|
||||||
// miniarena_test1();
|
miniarena_test1();
|
||||||
apool_test();
|
apool_test();
|
||||||
apool_test_autogrow();
|
apool_test_autogrow();
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -54,12 +54,6 @@ static INLINE void marena_temp_end(MTemp *state)
|
|||||||
arena->temp_level--;
|
arena->temp_level--;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define marena_push_type(allocator, type_)\
|
|
||||||
marenaalloc_aligned((allocator), sizeof(type_), _Alignof(type_))
|
|
||||||
#define marena_push_array(allocator, type_, nr_elements_)\
|
|
||||||
marenaalloc_aligned((allocator), (nr_elements_) * (U32)sizeof(type_), _Alignof(type_))
|
|
||||||
|
|
||||||
|
|
||||||
static INLINE void *marena_push(MArena *arena, U32 size)
|
static INLINE void *marena_push(MArena *arena, U32 size)
|
||||||
{
|
{
|
||||||
if (size > arena->size - arena->first_free) {
|
if (size > arena->size - arena->first_free) {
|
||||||
@@ -90,6 +84,12 @@ static INLINE void *marena_push_aligned(MArena *arena, U32 size, U32 align)
|
|||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define marena_push_type(arena, type_)\
|
||||||
|
marena_push_aligned((arena), sizeof(type_), _Alignof(type_))
|
||||||
|
#define marena_push_array(arena, type_, nr_elements_)\
|
||||||
|
marena_push_aligned((arena), (nr_elements_) * (U32)sizeof(type_), _Alignof(type_))
|
||||||
|
|
||||||
|
|
||||||
static INLINE void marena_reset(MArena *arena)
|
static INLINE void marena_reset(MArena *arena)
|
||||||
{
|
{
|
||||||
arena->first_free = 0;
|
arena->first_free = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user