| 1 | /** |
| 2 | * @file pm_memchr.h |
| 3 | * |
| 4 | * A custom memchr implementation. |
| 5 | */ |
| 6 | #ifndef PRISM_MEMCHR_H |
| 7 | #define PRISM_MEMCHR_H |
| 8 | |
| 9 | #include "prism/defines.h" |
| 10 | #include "prism/encoding.h" |
| 11 | |
| 12 | #include <stddef.h> |
| 13 | |
| 14 | /** |
| 15 | * We need to roll our own memchr to handle cases where the encoding changes and |
| 16 | * we need to search for a character in a buffer that could be the trailing byte |
| 17 | * of a multibyte character. |
| 18 | * |
| 19 | * @param source The source string. |
| 20 | * @param character The character to search for. |
| 21 | * @param number The maximum number of bytes to search. |
| 22 | * @param encoding_changed Whether the encoding changed. |
| 23 | * @param encoding A pointer to the encoding. |
| 24 | * @return A pointer to the first occurrence of the character in the source |
| 25 | * string, or NULL if no such character exists. |
| 26 | */ |
| 27 | void * pm_memchr(const void *source, int character, size_t number, bool encoding_changed, const pm_encoding_t *encoding); |
| 28 | |
| 29 | #endif |