44ed06f72c
Add README and LICENSE
2025-12-23 14:11:06 +01:00
c31fac9884
Fix more GCC warnings
2025-12-23 14:11:06 +01:00
973302fb31
Fix GCC errors
2025-12-23 14:11:06 +01:00
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
5d8fa1cc62
Fix allocation overflow for guf_dbuf and guf_dict
...
(Implement GUF_ALLOC_MAX_BYTES and GUF_ALLOC_MAX_CAPACITY).
2025-12-23 14:11:05 +01:00
52ca55f1d6
Improve guf_id_pool
2025-12-23 14:11:05 +01:00
81ab99ff15
Implement guf_str
2025-12-23 14:11:05 +01:00
517151b342
Change short-string approach to use 32 instead of 40 bytes
2025-12-23 14:11:05 +01:00
3d83ea0b17
Add 3x3 matrix inversion
2025-12-23 14:11:05 +01:00
7e348e74bc
Change linalg mat_inverse.
...
Still not sure whether it's better to calculate
rref[pivot_row][col] * (rref[row][pivot_col] / pivot_val) (option 1)
vs.
rref[pivot_row][col] * rref[row][pivot_col] / pivot_val (option 2)
(i.e. a * b / c vs. "a * (b/c))
in terms of floating point error.
But I think option 1 (current commit) is better, since the scale factor
(rref[row][pivot_col] / pivot_val) is always <= 1 here (I think).
2025-12-23 14:11:05 +01:00
ea6a63aa3a
Fix linalg bugs
2025-12-23 14:11:05 +01:00
bf5a8d9aac
Add guf_nearly_zero/one
2025-12-23 14:11:05 +01:00
5f16855dab
Add matrix inversion
2025-12-23 14:11:05 +01:00
93e9603218
Fix guf_dict size types
2025-12-23 14:11:05 +01:00
4a0a77d438
Rename GUF_STATIC_BUF_SIZE
2025-12-23 14:11:05 +01:00
ac9fa9f9ce
Add quaternion operations
2025-12-23 14:11:05 +01:00
57e405714d
Add linear algebra functions
2025-12-23 14:11:05 +01:00
d9114104c6
Add guf_str_view functions
2025-12-23 14:11:04 +01:00
f942cd8160
Add GUF_CSTR_TO_VIEW_CPP
2025-12-23 14:11:04 +01:00
2bf683906b
Add more dict tests
2025-12-23 14:11:04 +01:00
8197a5f45f
Add dict_erase tests
2025-12-23 14:11:04 +01:00
98774f842f
Fix guf_dict probing
2025-12-23 14:11:04 +01:00
6bed0d7616
Fix guf_dict growth bug
2025-12-23 14:11:04 +01:00
467f9be00a
Refactor
2025-12-23 14:11:04 +01:00
02cd5937a1
Make preserved_delims work (in guf_str_next_tok)
2025-12-23 14:11:04 +01:00
947041838e
Add tokeniser
2025-12-23 14:11:04 +01:00
d59d29f9f1
Add utf-8 handling
2025-12-23 14:11:04 +01:00
ead8bd8914
Work on utf-8
2025-12-23 14:11:04 +01:00
5e377a4c4d
Add more tests
2025-12-23 14:11:04 +01:00
d687bfe441
Improve tests
2025-12-23 14:11:04 +01:00
27d0cc65e4
Add C++ tests
2025-12-23 14:11:04 +01:00
0e4e3f392c
Improve iterator functions
2025-12-23 14:11:04 +01:00
ce1f465326
Fix dbuf iterator begin for dbuf.size == 0
2025-12-23 14:11:04 +01:00
df43178b15
Implement guf_dict
2025-12-23 14:11:04 +01:00
099ee09a94
Work on guf_dict
2025-12-23 14:11:04 +01:00
0b39cd3422
Add guf_rand with 32-bit operations (using xoshiro128** 1.1)
2025-12-23 14:11:04 +01:00
03638d5462
Fix overflow in guf_rand32range_i32 and guf_randrange_i64
2025-12-23 14:11:04 +01:00
c584279892
Add guf_rand32
2025-12-23 14:11:04 +01:00
77b5d60d6f
Add guf_rand
2025-12-23 14:11:04 +01:00
e01321b2b9
Change iterator
2025-12-23 14:11:04 +01:00
319ada61fd
Add iter index functions
2025-12-23 14:11:04 +01:00
f04a426489
Change sort function name
2025-12-23 14:11:04 +01:00
42f6a4e20d
Major refactor
2025-12-23 14:11:04 +01:00
6addd12dcd
Rewrite dbuf
2025-12-23 14:11:04 +01:00
f5d9c604e9
Add better error handling
2025-12-23 14:11:04 +01:00
71910a2404
Add integer functions
2025-12-23 14:11:04 +01:00
6256332f4c
Add dbuf_sort
2025-12-23 14:11:04 +01:00
ee7a81e4c1
Add cmp_void operators.
2025-12-23 14:11:04 +01:00
44ee8494d7
Use macro templates instead of void pointers
2025-12-23 14:11:04 +01:00