2022-12-21 08:29:33 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2023-02-25 17:58:23 +00:00
|
|
|
void *memchr(const void *ptr, int value, unsigned long num) {
|
2022-12-21 08:29:33 +00:00
|
|
|
const unsigned char *buf = ptr;
|
|
|
|
|
unsigned char val = value;
|
|
|
|
|
|
2023-02-25 17:58:23 +00:00
|
|
|
for (unsigned long i = 0; i < num; i++) {
|
2022-12-21 08:29:33 +00:00
|
|
|
if (buf[i] == val) {
|
|
|
|
|
return (void *)(buf + i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|