tsd.c (234370) | tsd.c (234543) |
---|---|
1#define JEMALLOC_TSD_C_ 2#include "jemalloc/internal/jemalloc_internal.h" 3 4/******************************************************************************/ 5/* Data. */ 6 7static unsigned ncleanups; 8static malloc_tsd_cleanup_t cleanups[MALLOC_TSD_CLEANUPS_MAX]; --- 18 unchanged lines hidden (view full) --- 27void 28malloc_tsd_no_cleanup(void *arg) 29{ 30 31 not_reached(); 32} 33 34#ifdef JEMALLOC_MALLOC_THREAD_CLEANUP | 1#define JEMALLOC_TSD_C_ 2#include "jemalloc/internal/jemalloc_internal.h" 3 4/******************************************************************************/ 5/* Data. */ 6 7static unsigned ncleanups; 8static malloc_tsd_cleanup_t cleanups[MALLOC_TSD_CLEANUPS_MAX]; --- 18 unchanged lines hidden (view full) --- 27void 28malloc_tsd_no_cleanup(void *arg) 29{ 30 31 not_reached(); 32} 33 34#ifdef JEMALLOC_MALLOC_THREAD_CLEANUP |
35JEMALLOC_ATTR(visibility("default")) |
|
35void 36_malloc_thread_cleanup(void) 37{ 38 bool pending[ncleanups], again; 39 unsigned i; 40 41 for (i = 0; i < ncleanups; i++) 42 pending[i] = true; 43 44 do { 45 again = false; 46 for (i = 0; i < ncleanups; i++) { 47 if (pending[i]) { | 36void 37_malloc_thread_cleanup(void) 38{ 39 bool pending[ncleanups], again; 40 unsigned i; 41 42 for (i = 0; i < ncleanups; i++) 43 pending[i] = true; 44 45 do { 46 again = false; 47 for (i = 0; i < ncleanups; i++) { 48 if (pending[i]) { |
48 pending[i] = cleanups[i].f(cleanups[i].arg); | 49 pending[i] = cleanups[i](); |
49 if (pending[i]) 50 again = true; 51 } 52 } 53 } while (again); 54} 55#endif 56 57void | 50 if (pending[i]) 51 again = true; 52 } 53 } 54 } while (again); 55} 56#endif 57 58void |
58malloc_tsd_cleanup_register(bool (*f)(void *), void *arg) | 59malloc_tsd_cleanup_register(bool (*f)(void)) |
59{ 60 61 assert(ncleanups < MALLOC_TSD_CLEANUPS_MAX); | 60{ 61 62 assert(ncleanups < MALLOC_TSD_CLEANUPS_MAX); |
62 cleanups[ncleanups].f = f; 63 cleanups[ncleanups].arg = arg; | 63 cleanups[ncleanups] = f; |
64 ncleanups++; 65} 66 67void 68malloc_tsd_boot(void) 69{ 70 71 ncleanups = 0; 72} | 64 ncleanups++; 65} 66 67void 68malloc_tsd_boot(void) 69{ 70 71 ncleanups = 0; 72} |