mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +00:00
Kernel: Add memchr
and malloc
to StdLib.cpp
These are needed by `libcxxabi`'s demangle support. `memchr` is taken straight-up from the `LibC/string.cpp` source code.
This commit is contained in:
parent
6f6b1b3ea1
commit
494ead3eb8
1 changed files with 16 additions and 0 deletions
|
@ -396,6 +396,22 @@ char* strstr(const char* haystack, const char* needle)
|
|||
return const_cast<char*>(haystack);
|
||||
}
|
||||
|
||||
void* memchr(const void* ptr, int c, size_t size)
|
||||
{
|
||||
char ch = c;
|
||||
auto* cptr = (const char*)ptr;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (cptr[i] == ch)
|
||||
return const_cast<char*>(cptr + i);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* malloc(size_t s)
|
||||
{
|
||||
return kmalloc(s);
|
||||
}
|
||||
|
||||
void* realloc(void* p, size_t s)
|
||||
{
|
||||
return krealloc(p, s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue