Formatting issue
This commit is contained in:
+56
-1
@@ -196,6 +196,8 @@ static void arena_test_allocator_interface(void)
|
|||||||
printf("test_4: allocated %u bytes page-aligned at %p\n", page_size, ptr);
|
printf("test_4: allocated %u bytes page-aligned at %p\n", page_size, ptr);
|
||||||
|
|
||||||
allocator_free_all(&allocator);
|
allocator_free_all(&allocator);
|
||||||
|
arena_free(&arena);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arena_test_decommit(void)
|
static void arena_test_decommit(void)
|
||||||
@@ -251,7 +253,7 @@ void miniarena_test1(void)
|
|||||||
Assert(arena.first_free == 0);
|
Assert(arena.first_free == 0);
|
||||||
U32 *val = marena_push_type(&arena, U32);
|
U32 *val = marena_push_type(&arena, U32);
|
||||||
*val = 0xa0b0c0d0;
|
*val = 0xa0b0c0d0;
|
||||||
printf("marena val %u\n", *val);
|
printf("marena val 0x%x\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);
|
||||||
Assert(arena.first_free == sizeof(U32));
|
Assert(arena.first_free == sizeof(U32));
|
||||||
@@ -308,8 +310,57 @@ void apool_test(void)
|
|||||||
printf("Pooltest %u\n",p->n);
|
printf("Pooltest %u\n",p->n);
|
||||||
}
|
}
|
||||||
allocator_free_all(&allocator);
|
allocator_free_all(&allocator);
|
||||||
|
arena_free(&arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void apool_test_miniarena(void)
|
||||||
|
{
|
||||||
|
TRACEF("\n");
|
||||||
|
|
||||||
|
MArena arena;
|
||||||
|
U8 data[4096];
|
||||||
|
marena_init(&arena, data, sizeof data);
|
||||||
|
Allocator allocator = marena_allocator(&arena);
|
||||||
|
APool *pool = apool_create_ex(&allocator, 16, sizeof(PoolTest), alignof(PoolTest));
|
||||||
|
PoolTest *list = NULL;
|
||||||
|
for (U32 i = 0; i < U32_Max; i++) {
|
||||||
|
PoolTest *pt = apool_alloc(pool);
|
||||||
|
if (pt == NULL){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pt->n = i;
|
||||||
|
pt->next = list;
|
||||||
|
list = pt;
|
||||||
|
}
|
||||||
|
for (PoolTest *p = list; p; p = p->next){
|
||||||
|
printf("Pooltest %u\n",p->n);
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolTest *next;
|
||||||
|
U32 count = 0;
|
||||||
|
for (PoolTest *p = list; count < 7 && p; p = next){
|
||||||
|
count++;
|
||||||
|
next = p->next;
|
||||||
|
printf("Pooltest freeing %u\n",p->n);
|
||||||
|
apool_free(pool, p);
|
||||||
|
}
|
||||||
|
list = NULL;
|
||||||
|
for (U32 i = 0; i < U32_Max; i++) {
|
||||||
|
PoolTest *pt = apool_alloc(pool);
|
||||||
|
if (pt == NULL){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pt->n = i;
|
||||||
|
pt->next = list;
|
||||||
|
list = pt;
|
||||||
|
}
|
||||||
|
for (PoolTest *p = list; p; p = p->next){
|
||||||
|
printf("Pooltest %u\n",p->n);
|
||||||
|
}
|
||||||
|
allocator_free_all(&allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void apool_test_autogrow(void)
|
void apool_test_autogrow(void)
|
||||||
{
|
{
|
||||||
TRACEF("\n");
|
TRACEF("\n");
|
||||||
@@ -356,6 +407,8 @@ void apool_test_autogrow(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
allocator_free_all(&allocator);
|
allocator_free_all(&allocator);
|
||||||
|
arena_free(&arena);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -369,5 +422,7 @@ int main(int argc, char *argv[])
|
|||||||
miniarena_test1();
|
miniarena_test1();
|
||||||
apool_test();
|
apool_test();
|
||||||
apool_test_autogrow();
|
apool_test_autogrow();
|
||||||
|
apool_test_miniarena();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ static void *platform_allocator_func(Allocator *allocator, AllocOperation operat
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
case Alloc_Op_Free_All:
|
case Alloc_Op_Free_All:
|
||||||
free(memory);;
|
NotImplemented;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user