diff --git a/src/core/strings/str8/str8.c b/src/core/strings/str8/str8.c index 5510285..b25e382 100644 --- a/src/core/strings/str8/str8.c +++ b/src/core/strings/str8/str8.c @@ -92,7 +92,15 @@ bool wapp_str8_equal(Str8RO *s1, Str8RO *s2) { return false; } - return memcmp(s1->buf, s2->buf, s1->size) == 0; + return wapp_str8_equal_to_count(s1, s2, s1->size); +} + +bool wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count) { + if (!s1 || !s2) { + return false; + } + + return memcmp(s1->buf, s2->buf, count) == 0; } Str8RO wapp_str8_substr(Str8RO *str, u64 start, u64 end) { diff --git a/src/core/strings/str8/str8.h b/src/core/strings/str8/str8.h index 39644b6..bc88ed3 100644 --- a/src/core/strings/str8/str8.h +++ b/src/core/strings/str8/str8.h @@ -67,6 +67,7 @@ Str8 *wapp_str8_alloc_str8(const Allocator *allocator, Str8RO *str); c8 wapp_str8_get(Str8RO *str, u64 index); void wapp_str8_set(Str8 *str, u64 index, c8 c); bool wapp_str8_equal(Str8RO *s1, Str8RO *s2); +bool wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count); Str8RO wapp_str8_substr(Str8RO *str, u64 start, u64 end); Str8 *wapp_str8_concat(const Allocator *allocator, Str8 *dst, Str8RO *src); void wapp_str8_concat_capped(Str8 *dst, Str8RO *src);