From: Arran Cudbard-Bell Date: Tue, 10 Dec 2019 08:16:26 +0000 (+0700) Subject: Add notes on heap allocations X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d06a54dac90dc71d1291415eec24a140435f424b;p=thirdparty%2Ffreeradius-server.git Add notes on heap allocations --- diff --git a/src/lib/util/thread_local.h b/src/lib/util/thread_local.h index 5fa309b6b84..0412e683ec6 100644 --- a/src/lib/util/thread_local.h +++ b/src/lib/util/thread_local.h @@ -49,8 +49,11 @@ typedef void (*pthread_destructor_t)(void*); * These should ONLY be called where __Thread_local is a pointer to heap * allocated memory that needs to be freed on thread exit. * - * For other types like ints _Thread_local should be used directly - * without the macros. + * Depending on the platform, the thread local storage itself may be freed + * before the destructor is called. + * + * The only way this code can work is if the value passed to the destructor + * initialisation is the address of non-TLS memory. */ /** Pre-initialise resources required for a thread local destructor *