| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2024 | ||
| 3 | ** my_memchr | ||
| 4 | ** File description: | ||
| 5 | ** Copies (size) bytes from memory area (source) to memory area (destination) | ||
| 6 | */ | ||
| 7 | /** | ||
| 8 | * @file my_memchr.c | ||
| 9 | * @brief The file containing the my_memchr function | ||
| 10 | * @author Nicolas TORO | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "mymemory.h" | ||
| 14 | |||
| 15 | 5 | void *my_memcpy(void *destination, const void *source, size_t size) | |
| 16 | { | ||
| 17 | 5 | char *ptr = destination; | |
| 18 | 5 | int end = 0; | |
| 19 | |||
| 20 |
3/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
|
5 | if (destination == NULL || source == NULL) |
| 21 | 1 | return NULL; | |
| 22 |
2/2✓ Branch 0 taken 50 times.
✓ Branch 1 taken 4 times.
|
54 | for (size_t index = 0; index < size; index++) { |
| 23 |
4/4✓ Branch 0 taken 27 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 25 times.
|
50 | if (end == 1 || ((char *)source)[index] == '\0') { |
| 24 | 25 | end = 1; | |
| 25 | 25 | ptr[index] = '\0'; | |
| 26 | } | ||
| 27 | 50 | ptr[index] = ((char *)source)[index]; | |
| 28 | } | ||
| 29 | 4 | return (void *)ptr; | |
| 30 | } | ||
| 31 |