| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2024 | ||
| 3 | ** my_memchr | ||
| 4 | ** File description: | ||
| 5 | ** Searches for the first occurrence of the character (c) | ||
| 6 | ** in the first (n) bytes of the string (s) | ||
| 7 | */ | ||
| 8 | /** | ||
| 9 | * @file my_memchr.c | ||
| 10 | * @brief The file containing the my_memchr function | ||
| 11 | * @author Nicolas TORO | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include "mymemory.h" | ||
| 15 | |||
| 16 | 3 | void *my_memchr(const void *memory_block, int searched_char, size_t size) | |
| 17 | { | ||
| 18 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | if (memory_block == NULL) |
| 19 | 1 | return NULL; | |
| 20 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
|
12 | for (size_t index = 0; index < size; index++) { |
| 21 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
|
11 | if (((char *)memory_block)[index] == searched_char) |
| 22 | 1 | return (void *)&((char *)memory_block)[index]; | |
| 23 | } | ||
| 24 | 1 | return NULL; | |
| 25 | } | ||
| 26 |