From dc837a6a6da014149c7bffd9c0870060dc9e1372 Mon Sep 17 00:00:00 2001 From: Martin Fouilleul Date: Mon, 11 Sep 2023 09:05:48 +0200 Subject: [PATCH] change len of strings to size_t --- src/runtime_memory.h | 2 +- src/util/macros.h | 3 ++- src/util/strings.h | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/runtime_memory.h b/src/runtime_memory.h index a54ab8d..e571c8f 100644 --- a/src/runtime_memory.h +++ b/src/runtime_memory.h @@ -73,7 +73,7 @@ void oc_wasm_list_push_back(oc_wasm_list* list, oc_wasm_list_elt* elt); typedef struct oc_wasm_str8 { u32 ptr; - u64 len; + u32 len; //NOTE: size_t is 4 bytes on wasm32 } oc_wasm_str8; typedef struct oc_wasm_str8_elt diff --git a/src/util/macros.h b/src/util/macros.h index d0c0651..c43c99d 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -111,7 +111,8 @@ inline T oc_cube(T a) #define oc_tga_variants(def, ...) \ def(u8, ##__VA_ARGS__) def(i8, ##__VA_ARGS__) def(u16, ##__VA_ARGS__) def(i16, ##__VA_ARGS__) \ def(u32, ##__VA_ARGS__) def(i32, ##__VA_ARGS__) def(u64, ##__VA_ARGS__) def(i64, ##__VA_ARGS__) \ - def(f32, ##__VA_ARGS__) def(f64, ##__VA_ARGS__) + def(size_t, ##__VA_ARGS__) \ + def(f32, ##__VA_ARGS__) def(f64, ##__VA_ARGS__) // This macro generates one _Generic association between a type and its variant #define oc_tga_association(type, name) , type : OC_CAT3(name, _, type) diff --git a/src/util/strings.h b/src/util/strings.h index 32da663..e3e44a3 100644 --- a/src/util/strings.h +++ b/src/util/strings.h @@ -35,7 +35,7 @@ extern "C" { typedef struct oc_str8 { char* ptr; - u64 len; + size_t len; } oc_str8; #define OC_STR8(s) ((oc_str8){ .len = (s) ? strlen(s) : 0, .ptr = (char*)s }) @@ -93,7 +93,7 @@ ORCA_API oc_str8_list oc_str8_split(oc_arena* arena, oc_str8 str, oc_str8_list s typedef struct oc_str16 { u16* ptr; - u64 len; + size_t len; } oc_str16; ORCA_API oc_str16 oc_str16_from_buffer(u64 len, u16* buffer); @@ -126,7 +126,7 @@ ORCA_API oc_str16_list oc_str16_split(oc_arena* arena, oc_str16 str, oc_str16_li typedef struct oc_str32 { u32* ptr; - u64 len; + size_t len; } oc_str32; ORCA_API oc_str32 oc_str32_from_buffer(u64 len, u32* buffer);