aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-07-23 23:55:28 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-07-23 23:55:28 +0200
commitb334a8494bef50c5b90adc1f101464fc8c4c971a (patch)
tree591efae83a93d25e45ab3b32d5d3d2e6c94d702b /libs/kstd
parent7d78433e6ea80b651f80201b6c5beef799887e7f (diff)
downloadkernel-b334a8494bef50c5b90adc1f101464fc8c4c971a.tar.xz
kernel-b334a8494bef50c5b90adc1f101464fc8c4c971a.zip
kernel: port ram disk to new driver architecture
Diffstat (limited to 'libs/kstd')
-rw-r--r--libs/kstd/kstd/cstring.hpp1
-rw-r--r--libs/kstd/kstd/libc/string.cpp15
2 files changed, 16 insertions, 0 deletions
diff --git a/libs/kstd/kstd/cstring.hpp b/libs/kstd/kstd/cstring.hpp
index bd8b28d8..9678f77f 100644
--- a/libs/kstd/kstd/cstring.hpp
+++ b/libs/kstd/kstd/cstring.hpp
@@ -12,6 +12,7 @@ namespace kstd::libc
auto memset(void * dest, int value, std::size_t size) noexcept -> void *;
auto memmove(void * dest, void const * src, std::size_t size) noexcept -> void *;
auto memcmp(void const * lhs, void const * rhs, std::size_t size) noexcept -> int;
+ auto memchr(void const * buffer, int character, std::size_t size) noexcept -> void *;
auto strlen(char const * string) noexcept -> std::size_t;
}
diff --git a/libs/kstd/kstd/libc/string.cpp b/libs/kstd/kstd/libc/string.cpp
index 15ecc70f..986f63a6 100644
--- a/libs/kstd/kstd/libc/string.cpp
+++ b/libs/kstd/kstd/libc/string.cpp
@@ -1,3 +1,5 @@
+#include <kstd/string.hpp>
+
#include <kstd/cstring.hpp>
#include <algorithm>
@@ -70,6 +72,19 @@ namespace kstd::libc
return dest;
}
+ auto memchr(void const * buffer, int character, std::size_t size) noexcept -> void *
+ {
+ auto as_char_ptr = reinterpret_cast<char const *>(buffer);
+ auto found = kstd::char_traits<char>::find(as_char_ptr, size, static_cast<char>(character));
+
+ if (found == as_char_ptr + size)
+ {
+ return nullptr;
+ }
+
+ return const_cast<void *>(static_cast<void const *>(found));
+ }
+
auto strlen(char const * string) noexcept -> std::size_t
{
return std::distance(string, std::ranges::find(string, nullptr, '\0'));