Bug 1301665 - [1.1] Statically initialize lib mapping array. r=glandium
authorEugen Sawin <esawin@mozilla.com>
Fri, 09 Sep 2016 14:32:48 +0200
changeset 354942 5011ecc316111a8c6a3a6260d2b9dab941405970
parent 354941 99ae6aab3d0b1ebc2be01e4dd95bbcc04c7422d5
child 354943 d1bf9267ba7da182771c43aec042f0f5f579de93
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1301665
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1301665 - [1.1] Statically initialize lib mapping array. r=glandium
mozglue/android/APKOpen.cpp
--- a/mozglue/android/APKOpen.cpp
+++ b/mozglue/android/APKOpen.cpp
@@ -78,17 +78,18 @@ enum StartupEvent {
 #define mozilla_StartupTimeline_Event(ev, z) ev,
 #include "StartupTimeline.h"
 #undef mozilla_StartupTimeline_Event
   MAX_STARTUP_EVENT_ID
 };
 
 using namespace mozilla;
 
-static struct mapping_info * lib_mapping = nullptr;
+static const int MAX_MAPPING_INFO = 32;
+static mapping_info lib_mapping[MAX_MAPPING_INFO];
 
 NS_EXPORT const struct mapping_info *
 getLibraryMapping()
 {
   return lib_mapping;
 }
 
 void
@@ -180,18 +181,16 @@ static void * nss_handle = nullptr;
 template <typename T> inline void
 xul_dlsym(const char *symbolName, T *value)
 {
   *value = (T) (uintptr_t) __wrap_dlsym(xul_handle, symbolName);
 }
 
 static int mapping_count = 0;
 
-#define MAX_MAPPING_INFO 32
-
 extern "C" void
 report_mapping(char *name, void *base, uint32_t len, uint32_t offset)
 {
   if (mapping_count >= MAX_MAPPING_INFO)
     return;
 
   struct mapping_info *info = &lib_mapping[mapping_count++];
   info->name = strdup(name);
@@ -260,19 +259,16 @@ loadSQLiteLibs(const char *apkName)
 {
   if (sqlite_handle)
     return SUCCESS;
 
 #ifdef MOZ_FOLD_LIBS
   if (loadNSSLibs(apkName) != SUCCESS)
     return FAILURE;
 #else
-  if (!lib_mapping) {
-    lib_mapping = (struct mapping_info *)calloc(MAX_MAPPING_INFO, sizeof(*lib_mapping));
-  }
 
   sqlite_handle = dlopenAPKLibrary(apkName, "libmozsqlite3.so");
   if (!sqlite_handle) {
     __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libmozsqlite3!");
     return FAILURE;
   }
 #endif
 
@@ -281,20 +277,16 @@ loadSQLiteLibs(const char *apkName)
 }
 
 static mozglueresult
 loadNSSLibs(const char *apkName)
 {
   if (nss_handle && nspr_handle && plc_handle)
     return SUCCESS;
 
-  if (!lib_mapping) {
-    lib_mapping = (struct mapping_info *)calloc(MAX_MAPPING_INFO, sizeof(*lib_mapping));
-  }
-
   nss_handle = dlopenAPKLibrary(apkName, "libnss3.so");
 
 #ifndef MOZ_FOLD_LIBS
   nspr_handle = dlopenAPKLibrary(apkName, "libnspr4.so");
 
   plc_handle = dlopenAPKLibrary(apkName, "libplc4.so");
 #endif