Remove gMallocLeakZygoteChild.

Remove this global variable and change the setting of it to non-zero
to a call to android_mallopt.

In addition, change the initialize function to use pass a bool* instead of
int*.

Bug: 130028357

Test: Ran malloc_debug/malloc_hooks/perfetto tests.
Change-Id: I20d382bdeaaf38aac6b9dcabea5b3dfab3c945f6
Merged-In: I20d382bdeaaf38aac6b9dcabea5b3dfab3c945f6
(cherry picked from commit 5225b342f0810c027df3d09fbbcef4d324b19b93)
diff --git a/libc/malloc_debug/PointerData.h b/libc/malloc_debug/PointerData.h
index 24ca748..c7958f3 100644
--- a/libc/malloc_debug/PointerData.h
+++ b/libc/malloc_debug/PointerData.h
@@ -44,7 +44,7 @@
 #include "OptionData.h"
 #include "UnwindBacktrace.h"
 
-extern int* g_malloc_zygote_child;
+extern bool* g_zygote_child;
 
 // Forward declarations.
 class Config;
@@ -89,7 +89,9 @@
   size_t hash_index;
   size_t RealSize() const { return size & ~(1U << 31); }
   bool ZygoteChildAlloc() const { return size & (1U << 31); }
-  static size_t GetEncodedSize(size_t size) { return GetEncodedSize(*g_malloc_zygote_child, size); }
+  static size_t GetEncodedSize(size_t size) {
+    return GetEncodedSize(*g_zygote_child, size);
+  }
   static size_t GetEncodedSize(bool child_alloc, size_t size) {
     return size | ((child_alloc) ? (1U << 31) : 0);
   }
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 1145796..91e1d26 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -58,7 +58,7 @@
 // ------------------------------------------------------------------------
 DebugData* g_debug;
 
-int* g_malloc_zygote_child;
+bool* g_zygote_child;
 
 const MallocDispatch* g_dispatch;
 // ------------------------------------------------------------------------
@@ -70,7 +70,7 @@
 // ------------------------------------------------------------------------
 __BEGIN_DECLS
 
-bool debug_initialize(const MallocDispatch* malloc_dispatch, int* malloc_zygote_child,
+bool debug_initialize(const MallocDispatch* malloc_dispatch, bool* malloc_zygote_child,
                       const char* options);
 void debug_finalize();
 void debug_dump_heap(const char* file_name);
@@ -225,15 +225,15 @@
   return g_debug->GetPointer(header);
 }
 
-bool debug_initialize(const MallocDispatch* malloc_dispatch, int* malloc_zygote_child,
+bool debug_initialize(const MallocDispatch* malloc_dispatch, bool* zygote_child,
                       const char* options) {
-  if (malloc_zygote_child == nullptr || options == nullptr) {
+  if (zygote_child == nullptr || options == nullptr) {
     return false;
   }
 
   InitAtfork();
 
-  g_malloc_zygote_child = malloc_zygote_child;
+  g_zygote_child = zygote_child;
 
   g_dispatch = malloc_dispatch;
 
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
index f611f3d..0238d10 100644
--- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
@@ -50,7 +50,7 @@
 
 __BEGIN_DECLS
 
-bool debug_initialize(const MallocDispatch*, int*, const char*);
+bool debug_initialize(const MallocDispatch*, bool*, const char*);
 void debug_finalize();
 
 void* debug_malloc(size_t);
@@ -103,8 +103,8 @@
   }
 
   void Init(const char* options) {
-    zygote = 0;
-    ASSERT_TRUE(debug_initialize(&dispatch, &zygote, options));
+    zygote_child = false;
+    ASSERT_TRUE(debug_initialize(&dispatch, &zygote_child, options));
     initialized = true;
   }
 
@@ -116,7 +116,7 @@
 
   bool initialized;
 
-  int zygote;
+  bool zygote_child;
 
   static MallocDispatch dispatch;
 };
@@ -1344,7 +1344,7 @@
   backtrace_fake_add(std::vector<uintptr_t> {0xa300, 0xb300});
 
   std::vector<void*> pointers;
-  zygote = 1;
+  zygote_child = true;
   pointers.push_back(debug_malloc(100));
   ASSERT_TRUE(pointers.back() != nullptr);
   pointers.push_back(debug_malloc(40));
@@ -1352,7 +1352,7 @@
   pointers.push_back(debug_malloc(200));
   ASSERT_TRUE(pointers.back() != nullptr);
 
-  zygote = 0;
+  zygote_child = false;
   pointers.push_back(debug_malloc(10));
   ASSERT_TRUE(pointers.back() != nullptr);
   pointers.push_back(debug_malloc(50));
@@ -1750,7 +1750,7 @@
   backtrace_fake_add(std::vector<uintptr_t> {0xbc000, 0xecd00, 0x12000});
   backtrace_fake_add(std::vector<uintptr_t> {0xbc000});
 
-  zygote = 1;
+  zygote_child = true;
 
   void* pointers[4];
   pointers[0] = debug_malloc(100);
@@ -1809,14 +1809,14 @@
   backtrace_fake_add(std::vector<uintptr_t> {0xbc000, 0xecd00, 0x12000});
   backtrace_fake_add(std::vector<uintptr_t> {0xbc000});
 
-  zygote = 1;
+  zygote_child = true;
   void* pointers[4];
   pointers[0] = debug_malloc(40);
   ASSERT_TRUE(pointers[0] != nullptr);
   pointers[1] = debug_malloc(40);
   ASSERT_TRUE(pointers[1] != nullptr);
 
-  zygote = 0;
+  zygote_child = false;
   pointers[2] = debug_malloc(40);
   ASSERT_TRUE(pointers[2] != nullptr);
   pointers[3] = debug_malloc(100);
@@ -1989,7 +1989,7 @@
   // Set all of the options.
   Init("guard fill backtrace leak_track free_track=2");
 
-  zygote = 1;
+  zygote_child = true;
 
   backtrace_fake_add(std::vector<uintptr_t> {0x1});