Update wapp array C API

This commit is contained in:
2025-12-07 21:56:16 +00:00
parent cf4a8a262e
commit 7d49ad78e6
10 changed files with 365 additions and 3991 deletions

View File

@@ -1,6 +1,7 @@
// vim:fileencoding=utf-8:foldmethod=marker
#include "str8.h"
#include "../../array/array.h"
#include "../../../common/aliases/aliases.h"
#include "../../../common/assert/assert.h"
#include "../../mem_allocator/mem_allocator.h"
@@ -260,14 +261,15 @@ void wapp_str8_to_upper(Str8 *dst, Str8RO *src) {
}
}
void wapp_str8_from_bytes(Str8 *dst, const U8Array *src) {
u64 size = src->count * src->item_size;
void wapp_str8_from_bytes(Str8 *dst, const u8 *src_byte_array) {
wapp_debug_assert(src_byte_array != NULL && dst != NULL, "`dst` and `src` should not be NULL");
u64 size = wapp_array_count(u8, src_byte_array) * wapp_array_item_size(u8, src_byte_array);
wapp_debug_assert(src != NULL && dst != NULL, "`dst` and `src` should not be NULL");
wapp_debug_assert(dst->capacity >= size, "`dst` does not have enough capacity");
dst->size = size;
memcpy(dst->buf, src->items, size);
memcpy(dst->buf, src_byte_array, size);
}
i64 wapp_str8_find(Str8RO *str, Str8RO substr) {