bc4a8918e2
Add string functions
2025-12-23 14:11:06 +01:00
1f37fbb404
Make guf_utf8_char 4 bytes instead of 5
...
(Null-termination was superfluous here.)
2025-12-23 14:11:06 +01:00
f073276bc5
Use least vs fast int types
2025-12-23 14:11:06 +01:00
d19177c275
Use portable guf_math_ckdint functions in guf_rand
2025-12-23 14:11:06 +01:00
8b29a707ab
Fix guf_id_pool integer portability
2025-12-23 14:11:06 +01:00
dfd2f0e4da
Fix guf_str uninit
2025-12-23 14:11:06 +01:00
6bf47f0ca6
Refactor to use portable minimum-width integers.
...
The signed and unsigned fixed-width integers (int32_t, uint32_t etc.) are optional
in C99 (and above). Use the non-optional minimum-width integers (int_fast32_t, uint_fast32_t and int_least32_t, uint_least32_t etc.) instead.
To simulate unsigned wrap-around, use the GUF_UWRAP macros in guf_common.h
cf. https://en.cppreference.com/w/c/types/integer (last-retrieved: 2025-05-18)
2025-12-23 14:11:06 +01:00
b7e3eec2c1
Add unsigned integer wrapping functions
2025-12-23 14:11:06 +01:00
5eb3c22a01
Add more dbuf_str tests
2025-12-23 14:11:06 +01:00
fad608e2ed
Fix failed assertion in guf_str_copy
...
An assertion GUF_ASSERT(str_is_valid(dst)) failed in guf_str_copy when it called guf_str_cstr(dst)
since guf_str_cstr assumes an already valid string, which was not the case when src was a short string.
Therefore, we get the dst's c_str now without calling guf_str_cstr(dst)
(Found by writing DbufStrTest.)
2025-12-23 14:11:06 +01:00
1a5a32d9b9
Prevent more potential int promotion bugs
2025-12-23 14:11:06 +01:00
bce0407674
Make signed guf_wrapping_mul more general
...
Don't fail on mod == 0 (in weird cases where the given UNSIGNED_TYPE_MAX == SIGNED_TYPE_MAX)
but
res = mod > 0 ? (1u * res % mod) : res;
2025-12-23 14:11:06 +01:00
26bab4efbe
Use better terminology for overflow and integer 'underflow'
2025-12-23 14:11:06 +01:00
7b2334a668
Fix potential int-promotion bugs in ckdint
...
Expressions like
(uin16_t)a * (uint16_t)b * (uint16_t)c
might be promoted to (signed) int (in that example, on platforms where sizeof(int) > sizeof(uint16_t)),
and therefore lead to undefined behaviour on overflow.
The above expression can be fixed as
1u * (uint16_t)a * (uint16_t)b * (uint16_t)c
(The 1u makes sure a, b, and c would be promoted to unsigned int (instead of int) on platforms where sizeof(int) > sizeof(uint16_t))
cf. https://stackoverflow.com/questions/27001604/32-bit-unsigned-multiply-on-64-bit-causing-undefined-behavior
2025-12-23 14:11:05 +01:00
5828c4ecec
Change C/CXX flags
2025-12-23 14:11:05 +01:00
64a71087b3
Refactor test
2025-12-23 14:11:05 +01:00
148cc741eb
Add static/non-static option for guf_alloc_libc.h
2025-12-23 14:11:05 +01:00
08b7edbdf4
Add name to alloc_tracker
2025-12-23 14:11:05 +01:00
9cec01cc50
Add guf_alloc_tracker
2025-12-23 14:11:05 +01:00
5cb2f240e0
Fix implementation defined behaviour in guf_wrapping_mul
2025-12-23 14:11:05 +01:00
dd4155d944
Add math_ckdint tests
2025-12-23 14:11:05 +01:00
26015e2380
Refactor tests
2025-12-23 14:11:05 +01:00
e3b18473f9
Add guf_math_ckdint IMPL_STATIC etc.
2025-12-23 14:11:05 +01:00
52d9f2c859
Add checked mul arithmetic
2025-12-23 14:11:05 +01:00
4111f54159
Add checked arithmetic
2025-12-23 14:11:05 +01:00
111023b7b1
Add guf_tok test
2025-12-23 14:11:05 +01:00
f5a91be8df
Add more guf_str tests
2025-12-23 14:11:05 +01:00
936a9dac56
Re-implement guf_str tokeniser
2025-12-23 14:11:05 +01:00
9b66649e01
Add guf_str hash functions
2025-12-23 14:11:05 +01:00
e923775769
Fix guf_str bugs and add tests
2025-12-23 14:11:05 +01:00
ac5e66b481
Minor guf_id_pool changes
2025-12-23 14:11:05 +01:00
e2036b768e
Fix guf_dict_init_with_capacity kv_idx_cap calculation
2025-12-23 14:11:05 +01:00
082b004391
Comment guf_rand
2025-12-23 14:11:05 +01:00
5d2c4be265
Add separate 32/64 bit versions to guf_rand
2025-12-23 14:11:05 +01:00
e8ea48dc45
Add guf_rand_splitmix32
2025-12-23 14:11:05 +01:00
4a231dc58f
Add guf_str_substr
2025-12-23 14:11:05 +01:00
883154f2ab
Add guf_dict_shrink_capacity
2025-12-23 14:11:05 +01:00
b1a5094d2b
Add more dict functions
2025-12-23 14:11:05 +01:00
ce4b25318d
Add comments
2025-12-23 14:11:05 +01:00
b541100a76
Change directory structure
2025-12-23 14:11:05 +01:00
0376fd3e99
Add more guf_str functions
2025-12-23 14:11:05 +01:00
eed418e6cd
Add changeable load factor
2025-12-23 14:11:05 +01:00
8b696b31fc
Add move- and copy ctors to dict and guf_str
2025-12-23 14:11:05 +01:00
e1bc585f68
Use SIZE_MAX instead of SIZE_T_MAX
2025-12-23 14:11:05 +01:00
25cf7f17b7
Fix dict asserts
2025-12-23 14:11:05 +01:00
c8ffde8c19
Fix warnings in release
2025-12-23 14:11:05 +01:00
e1af4f76a7
Replace puts with fputs in guf_err_to_str
2025-12-23 14:11:05 +01:00
ec9cd97631
Pass key_hash to guf_dict_find_idx to avoid re-computation
2025-12-23 14:11:05 +01:00
18f4496204
Fix GUF_DICT_64_BIT_IDX and guf_dict_max_capacity()
2025-12-23 14:11:05 +01:00
f3f7cec5f4
Use single u32/u64 as GUF_DICT_KV_META_T instead of two
2025-12-23 14:11:05 +01:00