@@ -426,6 +426,12 @@ __attribute__((constructor(FIRST_CTOR))) void iso_alloc_ctor(void) {
426426}
427427
428428INTERNAL_HIDDEN void flush_thread_caches () {
429+ LOCK_ROOT ();
430+ _flush_thread_caches ();
431+ UNLOCK_ROOT ();
432+ }
433+
434+ INTERNAL_HIDDEN INLINE void _flush_thread_caches () {
429435#if THREAD_SUPPORT && THREAD_CACHE
430436 /* The thread zone cache can be invalidated */
431437 memset (thread_zone_cache , 0x0 , sizeof (thread_zone_cache ));
@@ -467,7 +473,7 @@ INTERNAL_HIDDEN void _iso_alloc_destroy_zone(iso_alloc_zone *zone) {
467473 LOCK_ROOT ();
468474 UNMASK_ZONE_PTRS (zone );
469475 UNPOISON_ZONE (zone );
470- flush_thread_caches ();
476+ _flush_thread_caches ();
471477
472478 if (zone -> internally_managed == false) {
473479#if NEVER_REUSE_ZONES || FUZZ_MODE
@@ -522,7 +528,7 @@ INTERNAL_HIDDEN void _iso_alloc_destroy_zone(iso_alloc_zone *zone) {
522528__attribute__((destructor (LAST_DTOR ))) void iso_alloc_dtor (void ) {
523529 LOCK_ROOT ();
524530
525- flush_thread_caches ();
531+ _flush_thread_caches ();
526532
527533#if HEAP_PROFILER
528534 _iso_output_profile ();
@@ -812,7 +818,7 @@ INTERNAL_HIDDEN iso_alloc_zone *is_zone_usable(iso_alloc_zone *zone, size_t size
812818 UNMASK_ZONE_PTRS (zone );
813819
814820 /* If the cache for this zone is empty we should
815- * refill it to make future allocations faster
821+ * refill it to make future allocations faster
816822 * for all threads */
817823 if (zone -> free_bit_slot_cache_usable >= zone -> free_bit_slot_cache_index ) {
818824 fill_free_bit_slot_cache (zone );
@@ -1176,7 +1182,7 @@ INTERNAL_HIDDEN void *_iso_alloc(iso_alloc_zone *zone, size_t size) {
11761182#if THREAD_SUPPORT && THREAD_CACHE
11771183 if (LIKELY (zone == NULL ) && size <= SMALL_SZ_MAX ) {
11781184 for (int32_t i = 0 ; i < THREAD_CHUNK_CACHE_SZ ; i ++ ) {
1179- if (thread_chunk_cache [i ].chunk != NULL && thread_chunk_cache [i ].chunk_size >= size ){ // (size << WASTED_SZ_MULTIPLIER_SHIFT)) {
1185+ if (thread_chunk_cache [i ].chunk != NULL && thread_chunk_cache [i ].chunk_size >= (size << WASTED_SZ_MULTIPLIER_SHIFT )) {
11801186 void * p = thread_chunk_cache [i ].chunk ;
11811187 thread_chunk_cache [i ].chunk = NULL ;
11821188 thread_chunk_cache [i ].chunk_size = 0 ;
0 commit comments