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