Commit Graph

628 Commits

Author SHA1 Message Date
Christoffer Lerno
ea9a871d90 Fix incorrect doc contracts on interfaces. 2024-11-14 11:47:00 +01:00
Christoffer Lerno
84d010bb2f Remove accidental doc comment. 2024-11-14 11:14:02 +01:00
Walther Chen
758918c077 fix WriteBuffer.write_byte 2024-11-14 00:06:54 +01:00
konimarti
b7a095b4b4 Fix Formatter.floatformat and Object.to_format (#1602)
* fix: change float format specifier in Object.to_format

Fix the float format specifier in Object.to_format. If there is a float
stored in a Object such as 3.14, it would be printed out as 3 because
the format specifier is %d but should be %g.

* fix: print nan in floatformat

Fix floatformat to print 'nan' if float is nan. Currently,
io::printn(float.nan) will produce 'inf' instead of 'nan'.
2024-11-07 00:01:14 +01:00
Christoffer Lerno
08d1b29301 Add contracts on @catch / @ok. Taking the $typeof of a wildcard optional returns void! 2024-11-05 10:50:38 +01:00
Tomas Kallup
bdd6ed0e83 Fix: Unify termios types for actions & flags
The type for `Tcflags` was used instead of the CInt (now `Tcactions`)
and vice versa.
2024-11-04 17:15:40 +01:00
konimarti
8154e275fa encoding: implement RFC4648 base32 encoding (#1596)
Implement base32 encoding and decoding according to RFC 4648 with the
standard and extended hex alphabets. Add unit tests.

Link: https://www.rfc-editor.org/rfc/rfc4648
Signed-off-by: Koni Marti <koni.marti@gmail.com>
---------

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2024-11-04 12:19:28 +01:00
Christoffer Lerno
fd5b8d1374 Add bounds checking on List access. 2024-11-01 14:18:29 +01:00
Christoffer Lerno
827440686f $define would occasionally not properly evaluate declarations it encountered. 2024-10-30 11:59:18 +01:00
MohMaGen
0639659270 fix: remove requirements for pop_first. 2024-10-27 20:35:09 +01:00
Christoffer Lerno
4be08ee0bd string::new_struct_to_str and io::struct_to_format to dump struct data. io::print will now print structs. 2024-10-26 21:00:07 +02:00
Christoffer Lerno
83f8d24892 Update sponsors. More comments in path.c3 2024-10-26 13:00:54 +02:00
Walther Chen
fd1898b70a copy out keys also in HashMap.copy_keys (#1569)
* copy out keys also in HashMap.copy_keys
* test for copying keys out
2024-10-26 01:57:00 +02:00
Christoffer Lerno
78d5939d9d Show error when declarations do not start with fn in interfaces. #1565. Some added functionality to lists and time. 2024-10-18 17:10:00 +02:00
Christoffer Lerno
705856d51a - Disallow casting a void* to any or an interface, unless it is null.
- Defer resolution of declarations when looked up in `def` aliased #1559.
2024-10-16 12:50:47 +02:00
Christoffer Lerno
cf03bc0a0a Formatting fixes 2024-10-14 16:13:51 +02:00
Christoffer Lerno
31cd839063 Switch to <* *> docs. Fix issue with dynamically loaded C3 libs with other C3 code. 2024-10-14 02:14:34 +02:00
PavelBlinnikov
6a2957faf7 fix: segfault in panic when statically compiled
Co-authored-by: RoadToLP <ilya.titoff2013@yandex.ru>
2024-10-12 22:18:38 +02:00
Koni Marti
4e5ba327fe Fix mem leak in HashMap.keys_new_list
Fix a memory leak in HashMap.key_new_list(). The custom memory allocator
will not be used, since key_new_list() will call HashMap.copy_keys()
without passing the memory allocator along. Hence, HashMap.copy_keys()
will allocate on the heap and these memory blocks will not be freed.

To fix this, pass the custom allocator to HashMap.copy_keys(). Also,
since HashMap.key_new_list() is deprecated anyways, replace it by
HashMap.copy_keys().

Affected from this leak is Object.to_format() from
std::collection::object (for an ObjectInternalMap) which is used in the
JSON parser.

The tests for the JSON parser show the memory leak:

$ c3c compile-test test/unit/stdlib/encoding
$ valgrind --leak-check=yes ./testrun
==1454708==
==1454708== HEAP SUMMARY:
==1454708==     in use at exit: 384 bytes in 8 blocks
==1454708==   total heap usage: 69 allocs, 61 frees, 528,672 bytes allocated
==1454708==
==1454708== 48 bytes in 1 blocks are definitely lost in loss record 1 of 8
==1454708==    at 0x48447A8: malloc (vg_replace_malloc.c:446)
==1454708==    by 0x12CDBF: std.core.mem.allocator.LibcAllocator.acquire (libc_allocator.c3:42)
==1454708==    by 0x1790FD: malloc_try (mem_allocator.c3:64)
==1454708==    by 0x1790FD: alloc_array_try (mem_allocator.c3:286)
==1454708==    by 0x1790FD: alloc_array (mem_allocator.c3:269)
==1454708==    by 0x1790FD: copy_keys (hashmap.c3:310)
==1454708==    by 0x1790FD: std_collections_map$String$p$std.collections.object.Object$.HashMap.key
==1454708==    by 0x14D593: std.collections.object.Object.to_format (object.c3:53)
==1454708==    by 0x164556: std.io.Formatter.print_with_function (formatter.c3:86)
==1454708==    by 0x165B49: std.io.Formatter.out_str (formatter.c3:152)
==1454708==    by 0x16E2B0: std.io.Formatter.vprintf (formatter.c3:456)
==1454708==    by 0x12696B: std.core.dstring.DString.appendf (dstring.c3:532)
==1454708==    by 0x124EA9: std.core.string.tformat (string.c3:79)
==1454708==    by 0x113C79: json_test.test_string (json.c3:34)
==1454708==    by 0x118AA1: std.core.runtime.run_tests (runtime.c3:227)
==1454708==    by 0x1190B1: std.core.runtime.default_test_runner (runtime.c3:246)
==1454708==

[..snip..]

==1454708==
==1454708== LEAK SUMMARY:
==1454708==    definitely lost: 384 bytes in 8 blocks
==1454708==    indirectly lost: 0 bytes in 0 blocks
==1454708==      possibly lost: 0 bytes in 0 blocks
==1454708==    still reachable: 0 bytes in 0 blocks
==1454708==         suppressed: 0 bytes in 0 blocks
==1454708==
==1454708== For lists of detected and suppressed errors, rerun with: -s
==1454708== ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0)

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2024-10-11 13:52:34 +02:00
Christoffer Lerno
57ecadd23e Updated CSV API 2024-10-10 14:14:24 +02:00
Christoffer Lerno
bf59efd3f4 Fix sincos to be different on Darwin compared to other. 2024-10-09 16:14:24 +02:00
Christoffer Lerno
557adb6ed9 Update the init function of the arena allocator. 2024-10-09 12:45:50 +02:00
Christoffer Lerno
9f10996ac7 Bug when a continue is copied in a defer. 2024-10-08 22:13:30 +02:00
Christoffer Lerno
31f48829b0 Added CBool #1530. 2024-10-08 22:00:06 +02:00
Christoffer Lerno
39d4a97e24 Fix broken sincos function. 2024-10-08 20:34:41 +02:00
Christoffer Lerno
a665978b64 Fixing some whitespace issues. 2024-10-08 19:38:31 +02:00
Koni Marti
0cc62058a9 fix(string): use heap allocator for ZString.copy
Use the heap allocator for ZString.copy() instead of the temp allocator
to stay consistent across the code base.

The temp allocator is used for ZString.tcopy().
2024-10-08 17:33:29 +02:00
Christoffer Lerno
e3ea1d5049 Deprecate @adhoc, allow non-nested ad hoc generic types. 2024-10-08 11:02:10 +02:00
Fernando López Guevara
1a948e4341 fix(time): update month 2024-10-07 19:11:14 +02:00
Denis Palashevskii
217151be8d fix int formatting in std::collections::object 2024-10-05 14:03:27 +02:00
Christoffer Lerno
2ef1465244 Improved ObjC support. 2024-10-04 23:25:51 +02:00
Christoffer Lerno
77ac864995 Unexpected compile error using a typed constant with copysign #1517 2024-10-04 18:01:57 +02:00
Christoffer Lerno
fa4ca7944f - Add read/write to stream with big endian ints.
- Move accidently hidden "wrap_bytes".
2024-10-03 20:42:25 +02:00
Christoffer Lerno
02e9bfaf31 Separate const slice. Fix #1489. Fix const slice appending. Remove unintended print of char[] as String. Support const conversion of array -> slice. 2024-10-03 15:04:33 +02:00
Christoffer Lerno
1b8f8c5f5a Compiler crash when compiling c code in a library without --obj-out #1503. 2024-10-03 00:56:01 +02:00
Fernando López Guevara
131a783e89 feat(hash): added test for sha256 2024-10-02 16:55:17 +02:00
chri-k
2233f24c8f Add variants of DString.insert_at to match .append (#1510) 2024-10-02 10:22:59 +02:00
Christoffer Lerno
607a625641 Updated bigint. 2024-10-02 01:13:34 +02:00
Christoffer Lerno
9b49d19224 DString reverse and an initial BigInt implementation (untested), 2024-10-01 22:51:48 +02:00
Fernando López Guevara
c9b9de2838 fix(string): remove allocator argument on temp_ascii_to_lower 2024-09-30 22:01:44 +02:00
DanyDollaro
0d73f2fffa Added mutex tests (#1501)
* Added mutex tests. Add errorcheck in safe mode for Posix threads. Make non-recursive locks fail when used recursively on Windows. Fix thread pool tests. Simple locking count.

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
2024-09-30 20:57:16 +02:00
Christoffer Lerno
c8018c5543 Added generic PBKDF2 implementation. 2024-09-30 00:07:49 +02:00
chri-k
94abb3bd0c Fix escape sequence handling in encoding::json 2024-09-29 11:22:15 +02:00
Christoffer Lerno
3b009e0b50 Added generic HMAC. 2024-09-28 23:28:11 +02:00
Christoffer Lerno
cc130e04dd Added MD5 and crypto::safe_compare. 2024-09-28 22:16:25 +02:00
Christoffer Lerno
2eca868540 Add UUID generation. 2024-09-28 20:58:03 +02:00
Christoffer Lerno
8e7efaae99 ThreadPool is now adhoc available. 2024-09-28 13:28:39 +02:00
Alex Ling
fe9e434020 Fix incorrect to_gmt_offset result 2024-09-28 13:23:48 +02:00
Christoffer Lerno
8a0b0f5cf5 Disable fixed_pool where no threads are available. 2024-09-28 03:50:22 +02:00
Christoffer Lerno
5df321816b Unintended commit reverse. 2024-09-28 01:42:06 +02:00