From a08dd25eb79ed44ae06db2b95d4b44d77ea68110 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 19 Feb 2018 16:29:02 +0200 Subject: wrapper: use TLS heap storage for mangled symbols We do these calls a lot, so lets try keep the number of allocations down. --- src/wrapper/wrapper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wrapper/wrapper.c b/src/wrapper/wrapper.c index 5ed0943..a11de83 100644 --- a/src/wrapper/wrapper.c +++ b/src/wrapper/wrapper.c @@ -33,9 +33,11 @@ trace(const char *const symbol) // Holy fuck gcc what the fuck? Guess we don't use stack then, thanks int status; char *demangled; - if ((demangled = __cxa_demangle(symbol, NULL, NULL, &status))) { + static __thread char *data; + static __thread size_t size; + if ((demangled = __cxa_demangle(symbol, data, &size, &status))) { + data = (data != demangled ? demangled : data); printf("trace: %s\n", demangled); - free(demangled); // so pointless... return; } } -- cgit v1.2.3-70-g09d2