Implemented some basic libc functions and a text console
This commit is contained in:
14
libc/string/memchr.c
Normal file
14
libc/string/memchr.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <stddef.h>
|
||||
|
||||
const void *memchr(const void *ptr, int value, size_t num) {
|
||||
const unsigned char *buf = ptr;
|
||||
unsigned char val = value;
|
||||
|
||||
for (size_t i = 0; i < num; i++) {
|
||||
if (buf[i] == val) {
|
||||
return (void *)(buf + i);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user