curl-curl/tests
Viktor Szakats 193cb00ce9
build: stop overriding standard memory allocation functions
Before this patch curl used the C preprocessor to override standard
memory allocation symbols: malloc, calloc, strdup, realloc, free.
The goal of these is to replace them with curl's debug wrappers in
`CURLDEBUG` builds, another was to replace them with the wrappers
calling user-defined allocators in libcurl. This solution needed a bunch
of workarounds to avoid breaking external headers: it relied on include
order to do the overriding last. For "unity" builds it needed to reset
overrides before external includes. Also in test apps, which are always
built as single source files. It also needed the `(symbol)` trick
to avoid overrides in some places. This would still not fix cases where
the standard symbols were macros. It was also fragile and difficult
to figure out which was the actual function behind an alloc or free call
in a specific piece of code. This in turn caused bugs where the wrong
allocator was accidentally called.

To avoid these problems, this patch replaces this solution with
`curlx_`-prefixed allocator macros, and mapping them _once_ to either
the libcurl wrappers, the debug wrappers or the standard ones, matching
the rest of the code in libtests.

This concludes the long journey to avoid redefining standard functions
in the curl codebase.

Note: I did not update `packages/OS400/*.c` sources. They did not
`#include` `curl_setup.h`, `curl_memory.h` or `memdebug.h`, meaning
the overrides were never applied to them. This may or may not have been
correct. For now I suppressed the direct use of standard allocators
via a local `.checksrc`. Probably they (except for `curlcl.c`) should be
updated to include `curl_setup.h` and use the `curlx_` macros.

This patch changes mappings in two places:
- `lib/curl_threads.c` in libtests: Before this patch it mapped to
  libcurl allocators. After, it maps to standard allocators, like
  the rest of libtests code.
- `units`: before this patch it mapped to standard allocators. After, it
  maps to libcurl allocators.

Also:
- drop all position-dependent `curl_memory.h` and `memdebug.h` includes,
  and delete the now unnecessary headers.
- rename `Curl_tcsdup` macro to `curlx_tcsdup` and define like the other
  allocators.
- map `curlx_strdup()` to `_strdup()` on Windows (was: `strdup()`).
  To fix warnings silenced via `_CRT_NONSTDC_NO_DEPRECATE`.
- multibyte: map `curlx_convert_*()` to `_strdup()` on Windows
  (was: `strdup()`).
- src: do not reuse the `strdup` name for the local replacement.
- lib509: call `_strdup()` on Windows (was: `strdup()`).
- test1132: delete test obsoleted by this patch.
- CHECKSRC.md: update text for `SNPRINTF`.
- checksrc: ban standard allocator symbols.

Follow-up to b12da22db1 #18866
Follow-up to db98daab05 #18844
Follow-up to 4deea9396b #18814
Follow-up to 9678ff5b1b #18776
Follow-up to 10bac43b87 #18774
Follow-up to 20142f5d06 #18634
Follow-up to bf7375ecc5 #18503
Follow-up to 9863599d69 #18502
Follow-up to 3bb5e58c10 #17827

Closes #19626
2025-11-28 10:44:26 +01:00
..
certs badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
cmake lib: stop overriding system printf symbols 2025-10-06 20:57:59 +02:00
data build: stop overriding standard memory allocation functions 2025-11-28 10:44:26 +01:00
http pytest: disable two H3 earlydata tests for all platforms (was: macOS) 2025-11-27 15:51:47 +01:00
libtest build: stop overriding standard memory allocation functions 2025-11-28 10:44:26 +01:00
server build: stop overriding standard memory allocation functions 2025-11-28 10:44:26 +01:00
tunit build: stop overriding standard memory allocation functions 2025-11-28 10:44:26 +01:00
unit build: stop overriding standard memory allocation functions 2025-11-28 10:44:26 +01:00
.gitignore tidy-up: .gitignore lines mostly 2025-01-27 20:59:46 +01:00
allversions.pm badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
appveyor.pm tidy-up: whitespace (more in Perl) 2025-07-12 08:59:44 +02:00
azure.pm runtests: fix quoting in Appveyor and Azure test integration 2023-04-22 11:50:03 -07:00
CMakeLists.txt tests: replace remaining CR bytes with the new macro %CR 2025-11-06 20:45:45 +01:00
config.in copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
configurehelp.pm.in build: use configurehelp.pm.in with autotools and cmake 2024-09-21 12:21:14 +02:00
devtest.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
dictserver.py badwords: add more contractions, fix fallouts 2025-11-17 19:29:15 +01:00
directories.pm scripts: fix perl indentation, whitespace, semicolons 2025-04-29 19:35:55 +02:00
ech_combos.py tidy-up: miscellaneous 2025-11-17 13:32:43 +01:00
ech_tests.sh badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
ftpserver.pl badwords: add more contractions, fix fallouts 2025-11-17 19:29:15 +01:00
getpart.pm badwords: add more contractions, fix fallouts 2025-11-17 19:29:15 +01:00
globalconfig.pm runtests: add -m=seconds to override test curl command timeout 2025-11-19 22:04:52 +01:00
http2-server.pl tidy-up: miscellaneous 2025-11-17 13:32:43 +01:00
http3-server.pl tidy-up: miscellaneous 2025-11-17 13:32:43 +01:00
http-server.pl tidy-up: miscellaneous 2025-11-17 13:32:43 +01:00
Makefile.am build: stop overriding standard memory allocation functions 2025-11-28 10:44:26 +01:00
memanalyze.pl memdebug: produce stack trace dump with libbacktrace 2025-11-24 11:58:18 +01:00
negtelnetserver.py badwords: add more contractions, fix fallouts 2025-11-17 19:29:15 +01:00
nghttpx.conf copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
pathhelp.pm badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
processhelp.pm badwords: add more contractions, fix fallouts 2025-11-17 19:29:15 +01:00
requirements.txt GHA: bump the pip-dependencies group across 2 directories with 3 updates 2025-11-02 17:10:39 +01:00
rtspserver.pl tidy-up: miscellaneous 2025-11-17 13:32:43 +01:00
runner.pm runtests: add -m=seconds to override test curl command timeout 2025-11-19 22:04:52 +01:00
runtests.pl runtests: fix showing nghttpx-h3 in the Env: log when detected 2025-11-27 15:05:08 +01:00
secureserver.pl tidy-up: miscellaneous 2025-11-17 13:32:43 +01:00
serverhelp.pm badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
servers.pm badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
smbserver.py badwords: add more contractions, fix fallouts 2025-11-17 19:29:15 +01:00
sshhelp.pm runtests: fix test key format for libssh2 WinCNG (and others) 2025-03-23 20:26:26 +01:00
sshserver.pl tidy-up: miscellaneous 2025-11-17 13:32:43 +01:00
test745.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test971.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1119.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1135.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1139.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1140.pl badwords: re-sync with curl-www, fix issues found 2025-11-12 00:53:44 +01:00
test1165.pl build: add build-level CURL_DISABLE_TYPECHECK options 2025-11-21 13:48:35 +01:00
test1167.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1173.pl badwords: add more contractions, fix fallouts 2025-11-17 19:29:15 +01:00
test1175.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1177.pl NTLM_WB: drop support 2024-04-08 13:58:58 +02:00
test1222.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1275.pl scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
test1276.pl scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
test1477.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1486.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1488.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
test1544.pl scripts: fix perl indentation, whitespace, semicolons 2025-04-29 19:35:55 +02:00
test1707.pl scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
testcurl.pl badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
testutil.pm tests/data: more XML-compliance via %LT and %GT macros in email addresses 2025-11-18 18:57:53 +01:00
tftpserver.pl tidy-up: miscellaneous 2025-11-17 13:32:43 +01:00
util.py badwords: fix issues found in tests 2025-11-17 13:30:35 +01:00
valgrind.pm tests/valgrind.pm: fix warnings with no valgrind report to show 2024-09-20 15:40:07 +02:00
valgrind.supp hyper: drop support 2024-12-21 11:33:05 +01:00