| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2024 | ||
| 3 | ** my_malloc | ||
| 4 | ** File description: | ||
| 5 | ** The my_malloc.c | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include "mymemory.h" | ||
| 9 | |||
| 10 | 10 | void *my_malloc(size_t size, int type) | |
| 11 | { | ||
| 12 | static linked_list_t *list = NULL; | ||
| 13 | void *ptr; | ||
| 14 | |||
| 15 |
4/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1 times.
|
10 | if (type == 1 && size > 0) { |
| 16 | 7 | ptr = malloc(size); | |
| 17 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
|
7 | if (ptr == NULL) |
| 18 | 1 | return NULL; | |
| 19 | 6 | my_push_front(&list, ptr, VOID); | |
| 20 | 6 | return ptr; | |
| 21 | } | ||
| 22 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | if (type == 0) |
| 23 | 2 | my_delete_list(&list); | |
| 24 | 3 | return NULL; | |
| 25 | } | ||
| 26 |