tsd_setspecific(arena_key, save_arena);
save_malloc_hook = __malloc_hook; save_free_hook = __free_hook; __malloc_hook = malloc_starter; __free_hook = free_starter; #endif #ifdef _LIBC  if (__pthread_initialize != NULL) __pthread_initialize(); #endif mutex_init(&main_arena.mutex); mutex_init(&list_lock); tsd_key_create(&arena_key, NULL); tsd_setspecific(arena_key, (Void_t *)&main_arena); thread_atfork(ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_init_all); #endif
ptmalloc_init_all __MALLOC_P((void)){  arena *ar_ptr;#if defined _LIBC || defined MALLOC_HOOKS  tsd_setspecific(arena_key, save_arena);  __malloc_hook = save_malloc_hook;  __free_hook = save_free_hook;#endif  for(ar_ptr = &main_arena;;) {    (void)mutex_init(&ar_ptr->mutex);    ar_ptr = ar_ptr->next;    if(ar_ptr == &main_arena) break;  }  (void)mutex_init(&list_lock);}