Add wapp_str8_equal_to_count function

This commit is contained in:
Abdelrahman Said 2025-02-16 22:44:18 +00:00
parent a3d9bcf1a1
commit a308359942
2 changed files with 10 additions and 1 deletions

View File

@ -92,7 +92,15 @@ bool wapp_str8_equal(Str8RO *s1, Str8RO *s2) {
return false; 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) { Str8RO wapp_str8_substr(Str8RO *str, u64 start, u64 end) {

View File

@ -67,6 +67,7 @@ Str8 *wapp_str8_alloc_str8(const Allocator *allocator, Str8RO *str);
c8 wapp_str8_get(Str8RO *str, u64 index); c8 wapp_str8_get(Str8RO *str, u64 index);
void wapp_str8_set(Str8 *str, u64 index, c8 c); void wapp_str8_set(Str8 *str, u64 index, c8 c);
bool wapp_str8_equal(Str8RO *s1, Str8RO *s2); 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); Str8RO wapp_str8_substr(Str8RO *str, u64 start, u64 end);
Str8 *wapp_str8_concat(const Allocator *allocator, Str8 *dst, Str8RO *src); Str8 *wapp_str8_concat(const Allocator *allocator, Str8 *dst, Str8RO *src);
void wapp_str8_concat_capped(Str8 *dst, Str8RO *src); void wapp_str8_concat_capped(Str8 *dst, Str8RO *src);