feature (kernel): Implemented function to find the next matching char in a string

This commit is contained in:
antifallobst 2023-02-24 00:29:14 +01:00
parent 54d9a4ac7b
commit 970d570765
2 changed files with 13 additions and 9 deletions

View File

@ -23,6 +23,7 @@ typedef const char* string_t;
uint32_t string_length (string_t string);
bool string_compare (string_t a, string_t b);
uint32_t string_find_next (string_t string, char chr);
uint64_t variadic_format_size (string_t string, va_list args);
uint64_t format_size (string_t string, ...);

View File

@ -20,15 +20,7 @@
const char g_hex_chars[16] = "0123456789ABCDEF";
uint32_t string_length(string_t string) {
uint32_t n = 0;
char* c = (char*)string;
while(*c != '\0') {
c++;
n++;
}
return n;
return string_find_next(string, '\0');
}
bool string_compare(string_t a, string_t b) {
@ -40,6 +32,17 @@ bool string_compare(string_t a, string_t b) {
return memory_compare(a, b, a_len);
}
uint32_t string_find_next(string_t string, char chr) {
uint32_t n = 0;
while(*string != chr) {
string++;
n++;
}
return n;
}
uint64_t variadic_format_size(string_t string, va_list args) {
const char* buffer_in = (const char*)string;