tinycc/tests
Eric Raible be6584e2b9 Allow use of a custom allocator in libtcc
When using libtcc it's reasonable to be able to use the application's
memory allocator for all allocations, including tcc_new(), and including
#define MEM_DEBUG

Ideally the allocator would be stored in the TCCState, like TCCErrorFunc.
That would imply a new API tcc_new_with_allocator(), but more importantly
would require all uses of tcc_malloc(x) to be changed to s->tcc_malloc(x).
That's a non-starter in my book.

Instead I refactored the memory management code so that all allocations
flow through tcc_realloc().  Which simply calls a function pointer, the
default value of which is the previous tcc_realloc().

It then becomess trivial to install a new allocator with the new function:
LIBTCCAPI void tcc_set_realloc(TCCReallocFunc realloc);

The resulting code adds the trivial cost of an additional function call
per allocation/free.  It also doesn't distinguish between malloc failure
and realloc failure, but since both just fprintf then exit() that seems
unimportant to me.

On the plus side the preprocessor magic is much more clear.  The diffs
don't hightlight that, but take a look at the result to see if you agree.

All tests passed on my x86 linux box.
2024-02-06 20:01:18 -08:00
..
pp review recent commits 2024-02-04 18:18:40 +01:00
tests2 review recent commits 2024-02-04 18:18:40 +01:00
42test.h tccpp: Allow computed include like 42.h 2016-12-15 17:47:10 +01:00
abitest.c Allow use of a custom allocator in libtcc 2024-02-06 20:01:18 -08:00
arm-asm-testsuite.sh arm-asm: Add vcvt 2021-02-13 01:03:41 +01:00
asm-c-connect-1.c OpenBSD: testcases 2020-12-16 17:52:59 +01:00
asm-c-connect-2.c OpenBSD: testcases 2020-12-16 17:52:59 +01:00
asmtest.S x86asm: Add lzcnt/tzcnt support 2022-12-13 11:34:54 +01:00
boundtest.c Serveral updates 2021-01-12 18:06:23 +01:00
bug.c Allow const expr in builtin_frame_address/builtin_return_address 2023-01-16 08:37:47 +01:00
gcctestsuite.sh gcctestsuite: Make the script usable on more systems, skip some tests 2022-10-12 00:59:02 +02:00
libtcc_test_mt.c stuff & fixes 2023-09-06 22:42:30 +02:00
libtcc_test.c Add error_func and error_opaque getters to libtcc 2019-10-14 09:36:14 +02:00
Makefile Revert "tests: Add support for codesigning command." 2023-10-30 19:08:57 +01:00
tcctest.c review recent commits 2024-02-04 18:18:40 +01:00
tcctest.h tccpp: Implement __BASE_FILE__ macro 2016-12-15 17:47:08 +01:00
testfp.c Remove misc. files 2016-10-01 20:27:41 +02:00
vla_test.c Improved variable length array support. 2013-04-27 22:58:52 +01:00