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