Bug 967553 - Restore to using __wrap_free. r=gcp, a=sledru
authorJim Chen <nchen@mozilla.com>
Wed, 05 Feb 2014 13:39:48 -0500
changeset 177002 c489dd0f3ccf2bd249e94c3e2d925fc1fa27f135
parent 177001 4639d13d1ccf71ab37e9d3d573c77ac7f8fc6c8b
child 177003 fc402a7182ef27631c3ffa904316f69115e65bff
push id5228
push userryanvm@gmail.com
push dateThu, 13 Feb 2014 16:03:34 +0000
treeherdermozilla-aurora@8b2cc1963145 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp, sledru
bugs967553
milestone29.0a2
Bug 967553 - Restore to using __wrap_free. r=gcp, a=sledru
mozglue/android/NSSBridge.cpp
mozglue/android/SQLiteBridge.cpp
--- a/mozglue/android/NSSBridge.cpp
+++ b/mozglue/android/NSSBridge.cpp
@@ -8,23 +8,16 @@
 #include "APKOpen.h"
 #ifdef ANDROID
 #include <jni.h>
 #include <android/log.h>
 #endif
 
 #include "ElfLoader.h"
 
-#ifdef MOZ_MEMORY
-// libc's free().
-extern "C" void __real_free(void *);
-#else
-#define __real_free(a) free(a)
-#endif
-
 #ifdef DEBUG
 #define LOG(x...) __android_log_print(ANDROID_LOG_INFO, "GeckoJNI", x)
 #else
 #define LOG(x...)
 #endif
 
 static bool initialized = false;
 
@@ -86,18 +79,17 @@ throwError(JNIEnv* jenv, const char * fu
     char *msg;
 
     PRErrorCode perr = f_PR_GetError();
     char * errString = f_PR_ErrorToString(perr, 0);
     asprintf(&msg, "%s returned error %d: %s\n", funcString, perr, errString);
     LOG("Throwing error: %s\n", msg);
 
     JNI_Throw(jenv, "java/lang/Exception", msg);
-    // msg is allocated by asprintf, it needs to be freed by libc.
-    __real_free(msg);
+    free(msg);
     LOG("Error thrown\n");
 }
 
 extern "C" NS_EXPORT jstring JNICALL
 Java_org_mozilla_gecko_NSSBridge_nativeEncrypt(JNIEnv* jenv, jclass,
                                                jstring jPath,
                                                jstring jValue)
 {
--- a/mozglue/android/SQLiteBridge.cpp
+++ b/mozglue/android/SQLiteBridge.cpp
@@ -6,23 +6,16 @@
 #include <stdio.h>
 #include <jni.h>
 #include <android/log.h>
 #include "dlfcn.h"
 #include "APKOpen.h"
 #include "ElfLoader.h"
 #include "SQLiteBridge.h"
 
-#ifdef MOZ_MEMORY
-// libc's free().
-extern "C" void __real_free(void *);
-#else
-#define __real_free(a) free(a)
-#endif
-
 #ifdef DEBUG
 #define LOG(x...) __android_log_print(ANDROID_LOG_INFO, "GeckoJNI", x)
 #else
 #define LOG(x...)
 #endif
 
 #define SQLITE_WRAPPER_INT(name) name ## _t f_ ## name;
 
@@ -80,18 +73,17 @@ static jobject sqliteInternalCall(JNIEnv
 static void throwSqliteException(JNIEnv* jenv, const char* aFormat, ...)
 {
     va_list ap;
     va_start(ap, aFormat);
     char* msg = nullptr;
     vasprintf(&msg, aFormat, ap);
     LOG("Error in SQLiteBridge: %s\n", msg);
     JNI_Throw(jenv, "org/mozilla/gecko/sqlite/SQLiteBridgeException", msg);
-    // msg is allocated by vasprintf, it needs to be freed by libc.
-    __real_free(msg);
+    free(msg);
     va_end(ap);
 }
 
 static void
 JNI_Setup(JNIEnv* jenv)
 {
     if (initialized) return;