From b334a8494bef50c5b90adc1f101464fc8c4c971a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 23 Jul 2026 23:55:28 +0200 Subject: kernel: port ram disk to new driver architecture --- libs/kstd/kstd/cstring.hpp | 1 + libs/kstd/kstd/libc/string.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'libs/kstd') 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 + #include #include @@ -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(buffer); + auto found = kstd::char_traits::find(as_char_ptr, size, static_cast(character)); + + if (found == as_char_ptr + size) + { + return nullptr; + } + + return const_cast(static_cast(found)); + } + auto strlen(char const * string) noexcept -> std::size_t { return std::distance(string, std::ranges::find(string, nullptr, '\0')); -- cgit v1.2.3