about summary refs log tree commit diff
path: root/malloc/arena.c
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2021-07-22 18:38:04 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2021-07-22 18:38:04 +0530
commitcc35896ea3e4532919ec81b17f36299117debe79 (patch)
tree8c8f6ebcd9774a5a48a689f9e639899a0050b7ab /malloc/arena.c
parentc142eb253f3814f46527e9b37484041dd85702cf (diff)
downloadglibc-cc35896ea3e4532919ec81b17f36299117debe79.tar.gz
glibc-cc35896ea3e4532919ec81b17f36299117debe79.tar.xz
glibc-cc35896ea3e4532919ec81b17f36299117debe79.zip
Simplify __malloc_initialized
Now that mcheck no longer needs to check __malloc_initialized (and no
other third party hook can since the symbol is not exported), make the
variable boolean and static so that it is used strictly within malloc.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'malloc/arena.c')
-rw-r--r--malloc/arena.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/malloc/arena.c b/malloc/arena.c
index 9111b49589..840426f9fb 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -97,7 +97,7 @@ static mstate free_list;
 __libc_lock_define_initialized (static, list_lock);
 
 /* Already initialized? */
-int __malloc_initialized = -1;
+static bool __malloc_initialized = false;
 
 /**************************************************************************/
 
@@ -143,7 +143,7 @@ int __malloc_initialized = -1;
 void
 __malloc_fork_lock_parent (void)
 {
-  if (__malloc_initialized < 1)
+  if (!__malloc_initialized)
     return;
 
   /* We do not acquire free_list_lock here because we completely
@@ -163,7 +163,7 @@ __malloc_fork_lock_parent (void)
 void
 __malloc_fork_unlock_parent (void)
 {
-  if (__malloc_initialized < 1)
+  if (!__malloc_initialized)
     return;
 
   for (mstate ar_ptr = &main_arena;; )
@@ -179,7 +179,7 @@ __malloc_fork_unlock_parent (void)
 void
 __malloc_fork_unlock_child (void)
 {
-  if (__malloc_initialized < 1)
+  if (!__malloc_initialized)
     return;
 
   /* Push all arenas to the free list, except thread_arena, which is
@@ -286,10 +286,10 @@ static void tcache_key_initialize (void);
 static void
 ptmalloc_init (void)
 {
-  if (__malloc_initialized >= 0)
+  if (__malloc_initialized)
     return;
 
-  __malloc_initialized = 0;
+  __malloc_initialized = true;
 
 #if USE_TCACHE
   tcache_key_initialize ();