Remove extra argument for malloc_tsd_cleanup_register
Bookkeeping an extra argument that actually only stores a function pointer for a function we already have is not very useful.
This commit is contained in:
parent
8ad483fe60
commit
13067ec835
@ -4,11 +4,7 @@
|
|||||||
/* Maximum number of malloc_tsd users with cleanup functions. */
|
/* Maximum number of malloc_tsd users with cleanup functions. */
|
||||||
#define MALLOC_TSD_CLEANUPS_MAX 8
|
#define MALLOC_TSD_CLEANUPS_MAX 8
|
||||||
|
|
||||||
typedef struct malloc_tsd_cleanup_s malloc_tsd_cleanup_t;
|
typedef bool (*malloc_tsd_cleanup_t)(void);
|
||||||
struct malloc_tsd_cleanup_s {
|
|
||||||
bool (*f)(void *);
|
|
||||||
void *arg;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TLS/TSD-agnostic macro-based implementation of thread-specific data. There
|
* TLS/TSD-agnostic macro-based implementation of thread-specific data. There
|
||||||
@ -110,13 +106,12 @@ a_attr bool a_name##_booted = false;
|
|||||||
a_cleanup) \
|
a_cleanup) \
|
||||||
/* Initialization/cleanup. */ \
|
/* Initialization/cleanup. */ \
|
||||||
a_attr bool \
|
a_attr bool \
|
||||||
a_name##_tsd_cleanup_wrapper(void *arg) \
|
a_name##_tsd_cleanup_wrapper(void) \
|
||||||
{ \
|
{ \
|
||||||
bool (*cleanup)(void *) = arg; \
|
|
||||||
\
|
\
|
||||||
if (a_name##_initialized) { \
|
if (a_name##_initialized) { \
|
||||||
a_name##_initialized = false; \
|
a_name##_initialized = false; \
|
||||||
cleanup(&a_name##_tls); \
|
a_cleanup(&a_name##_tls); \
|
||||||
} \
|
} \
|
||||||
return (a_name##_initialized); \
|
return (a_name##_initialized); \
|
||||||
} \
|
} \
|
||||||
@ -126,7 +121,7 @@ a_name##_tsd_boot(void) \
|
|||||||
\
|
\
|
||||||
if (a_cleanup != malloc_tsd_no_cleanup) { \
|
if (a_cleanup != malloc_tsd_no_cleanup) { \
|
||||||
malloc_tsd_cleanup_register( \
|
malloc_tsd_cleanup_register( \
|
||||||
&a_name##_tsd_cleanup_wrapper, a_cleanup); \
|
&a_name##_tsd_cleanup_wrapper); \
|
||||||
} \
|
} \
|
||||||
a_name##_booted = true; \
|
a_name##_booted = true; \
|
||||||
return (false); \
|
return (false); \
|
||||||
@ -290,7 +285,7 @@ a_name##_tsd_set(a_type *val) \
|
|||||||
void *malloc_tsd_malloc(size_t size);
|
void *malloc_tsd_malloc(size_t size);
|
||||||
void malloc_tsd_dalloc(void *wrapper);
|
void malloc_tsd_dalloc(void *wrapper);
|
||||||
void malloc_tsd_no_cleanup(void *);
|
void malloc_tsd_no_cleanup(void *);
|
||||||
void malloc_tsd_cleanup_register(bool (*f)(void *), void *arg);
|
void malloc_tsd_cleanup_register(bool (*f)(void));
|
||||||
void malloc_tsd_boot(void);
|
void malloc_tsd_boot(void);
|
||||||
|
|
||||||
#endif /* JEMALLOC_H_EXTERNS */
|
#endif /* JEMALLOC_H_EXTERNS */
|
||||||
|
@ -46,7 +46,7 @@ _malloc_thread_cleanup(void)
|
|||||||
again = false;
|
again = false;
|
||||||
for (i = 0; i < ncleanups; i++) {
|
for (i = 0; i < ncleanups; i++) {
|
||||||
if (pending[i]) {
|
if (pending[i]) {
|
||||||
pending[i] = cleanups[i].f(cleanups[i].arg);
|
pending[i] = cleanups[i]();
|
||||||
if (pending[i])
|
if (pending[i])
|
||||||
again = true;
|
again = true;
|
||||||
}
|
}
|
||||||
@ -56,12 +56,11 @@ _malloc_thread_cleanup(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
malloc_tsd_cleanup_register(bool (*f)(void *), void *arg)
|
malloc_tsd_cleanup_register(bool (*f)(void))
|
||||||
{
|
{
|
||||||
|
|
||||||
assert(ncleanups < MALLOC_TSD_CLEANUPS_MAX);
|
assert(ncleanups < MALLOC_TSD_CLEANUPS_MAX);
|
||||||
cleanups[ncleanups].f = f;
|
cleanups[ncleanups] = f;
|
||||||
cleanups[ncleanups].arg = arg;
|
|
||||||
ncleanups++;
|
ncleanups++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user