diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2023-09-22 20:23:05 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2023-09-22 20:23:05 +0200 |
commit | 242b87209b778d033d1da828ae9ec47170c17f38 (patch) | |
tree | 5394ab5babacc3c8cf542ab113ffe4a2a6c0edf9 /include | |
parent | 3e6812f8f97ba884f39b01200e2bedeed89cf5c2 (diff) | |
download | kit-242b87209b778d033d1da828ae9ec47170c17f38.zip |
fix single header
Diffstat (limited to 'include')
-rw-r--r-- | include/kit.inl.h | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/include/kit.inl.h b/include/kit.inl.h index 1b66297..9752919 100644 --- a/include/kit.inl.h +++ b/include/kit.inl.h @@ -1,9 +1,9 @@ // ================================================================ // // kit.inl.h -// https://guattari.tech/git/?p=kit.git;a=tree +// https://guattari.tech/kit.git // -// Header-only utility library for C. +// Single header-only utility library for C. // // ================================================================ // @@ -2869,6 +2869,48 @@ void thrd_yield(void) { #endif /********************************************************************* * * + * File: source/kit/array_ref.c * + * * + *********************************************************************/ +#include <string.h> +i8 kit_ar_equal_bytes(i64 left_element_size, i64 left_size, + void *left_data, i64 right_element_size, + i64 right_size, void *right_data) { + i64 i; + if (left_element_size != right_element_size) + return 0; + if (left_size != right_size) + return 0; + for (i = 0; i < left_size; i++) + if (memcmp((u8 *) left_data + i * left_element_size, + (u8 *) right_data + i * left_element_size, + left_element_size) != 0) + return 0; + return 1; +} +i8 kit_ar_compare(i64 left_element_size, i64 left_size, + void *left_data, i64 right_element_size, + i64 right_size, void *right_data, + kit_ar_compare_fn compare) { + i64 i; + if (left_element_size < right_element_size) + return -1; + if (left_element_size > right_element_size) + return 1; + for (i = 0; i < left_size && i < right_size; i++) { + i8 c = compare((u8 *) left_data + i * left_element_size, + (u8 *) right_data + i * left_element_size); + if (c != 0) + return c; + } + if (left_size < right_size) + return -1; + if (left_size > right_size) + return 1; + return 0; +} +/********************************************************************* + * * * File: source/kit/dynamic_array.c * * * *********************************************************************/ |