summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-02-19 16:29:02 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-02-19 16:29:02 +0200
commita08dd25eb79ed44ae06db2b95d4b44d77ea68110 (patch)
tree5f851ca9d7279b66c647085fcf25c09de8812582 /src
parentda200d3ac0204abadd5992820486321970d689b8 (diff)
wrapper: use TLS heap storage for mangled symbols
We do these calls a lot, so lets try keep the number of allocations down.
Diffstat (limited to 'src')
-rw-r--r--src/wrapper/wrapper.c6
1 files changed, 4 insertions, 2 deletions
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;
}
}