Update wapp array C API

This commit is contained in:
2025-12-07 21:56:16 +00:00
committed by Abdelrahman Said
parent 551836d4c8
commit 2b49bfcdbf
10 changed files with 365 additions and 3991 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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) {

View File

@@ -99,7 +99,7 @@ void wapp_str8_copy_to_cstr(char *dst, Str8RO *src, u64 dst_capacity);
void wapp_str8_format(Str8 *dst, const char *format, ...);
void wapp_str8_to_lower(Str8 *dst, Str8RO *src);
void wapp_str8_to_upper(Str8 *dst, Str8RO *src);
void wapp_str8_from_bytes(Str8 *dst, const U8Array *src);
void wapp_str8_from_bytes(Str8 *dst, const u8 *src);
/**
* Str8 find functions