19 Commits

Author SHA1 Message Date
jun
ec074d5753 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-05-15 08:46:54 +02:00
jun
37f9011166 Add guf_alloc_tracker 2025-05-14 14:47:20 +02:00
jun
873cdf20b1 Add checked mul arithmetic 2025-05-13 12:45:17 +02:00
jun
9c417d2aa1 Add checked arithmetic 2025-05-11 08:55:03 +02:00
jun
c4b68d5ad2 Add guf_tok test 2025-05-09 15:43:52 +02:00
jun
e98dc3b91e Fix guf_str bugs and add tests 2025-04-24 01:43:24 +02:00
jun
c039e24996 Use SIZE_MAX instead of SIZE_T_MAX 2025-03-19 23:03:10 +01:00
jun
29014f4c52 Fix dict asserts 2025-03-19 19:16:31 +01:00
jun
48b366d8e9 Fix warnings in release 2025-03-19 18:29:52 +01:00
jun
b01e087c85 Fix GUF_DICT_64_BIT_IDX and guf_dict_max_capacity() 2025-03-19 16:16:41 +01:00
jun
e535d39e3d Fix allocation overflow for guf_dbuf and guf_dict
(Implement GUF_ALLOC_MAX_BYTES and GUF_ALLOC_MAX_CAPACITY).
2025-03-18 13:43:36 +01:00
jun
ad884ee1e9 Implement guf_str 2025-03-17 21:17:07 +01:00
jun
ae104919e0 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-03-07 21:24:53 +01:00
jun
e489dd694b Add quaternion operations 2025-03-06 11:52:24 +01:00
jun
9d62df6a83 Add more dict tests 2025-03-04 06:52:42 +01:00
jun
8e6ffcdc70 Add dict_erase tests 2025-03-03 16:14:13 +01:00
jun
cd1c1cd5db Refactor 2025-03-02 18:25:54 +01:00
jun
217622d816 Add tokeniser 2025-02-27 10:21:21 +01:00
jun
60e2849b01 Work on utf-8 2025-02-26 03:57:04 +01:00