create get_chunk func to simplify

This commit is contained in:
2024-07-31 15:04:58 +02:00
parent c7e205c8e5
commit 5ebe1346ac
6 changed files with 44 additions and 27 deletions

View File

@ -37,13 +37,13 @@ int main(int ac, char **av)
ptr1 = ft_malloc(10000000);
ptr2 = ft_malloc(10000000);
ptr3 = ft_malloc(10000000);
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr1) == NULL), "alloc first", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr2) == NULL), "alloc second", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr3) == NULL), "alloc third", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[LARGE], ptr1) == NULL), "alloc first", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[LARGE], ptr2) == NULL), "alloc second", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[LARGE], ptr3) == NULL), "alloc third", "");
ft_free(ptr1);
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr2) == NULL), "free disorder1", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[LARGE], ptr2) == NULL), "free disorder1", "");
ft_free(ptr3);
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[LARGE], ptr2) == NULL), "free disorder2", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[LARGE], ptr2) == NULL), "free disorder2", "");
ft_free(ptr2);
test(NULL, allocs_tree[LARGE], "free disorder3", "");
@ -57,13 +57,13 @@ int main(int ac, char **av)
ptr1 = ft_malloc(4);
ptr2 = ft_malloc(4);
ptr3 = ft_malloc(4);
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[TINY], ptr1) == NULL), "alloc first", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[TINY], ptr2) == NULL), "alloc second", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[TINY], ptr3) == NULL), "alloc third", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[TINY], ptr1) == NULL), "alloc first", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[TINY], ptr2) == NULL), "alloc second", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[TINY], ptr3) == NULL), "alloc third", "");
ft_free(ptr1);
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[TINY], ptr2) == NULL), "free disorder1", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[TINY], ptr2) == NULL), "free disorder1", "");
ft_free(ptr3);
test(0, (const void*) (uintptr_t) (raw_get_chunk(allocs_tree[TINY], ptr2) == NULL), "free disorder2", "");
test(0, (const void*) (uintptr_t) (raw_get_chunk_by_root(allocs_tree[TINY], ptr2) == NULL), "free disorder2", "");
ft_free(ptr2);
test(NULL, allocs_tree[TINY], "free disorder3", "");
show_alloc_mem();