Bug 872577 - Using default resolution for free() instead of libc. r=nfroyd
☠☠ backed out by 31f4b8658e3e ☠ ☠
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Tue, 13 Aug 2013 16:04:40 +0200
changeset 142407 9baba7e5b351eed735b4c520689f7e174b1784f5
parent 142406 fc38877460ecd88225eefdb394941771bf34c966
child 142408 b3299b797d8d6d177a9de7a9a518ae5fc2bf2f05
push id32388
push usercholler@mozilla.com
push dateTue, 13 Aug 2013 14:06:08 +0000
treeherdermozilla-inbound@9baba7e5b351 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs872577
milestone26.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 872577 - Using default resolution for free() instead of libc. r=nfroyd
toolkit/components/osfile/modules/osfile_unix_back.jsm
--- a/toolkit/components/osfile/modules/osfile_unix_back.jsm
+++ b/toolkit/components/osfile/modules/osfile_unix_back.jsm
@@ -223,20 +223,35 @@
                         /*return */ctypes.int,
                         /*dirp*/   Types.DIR.in_ptr.implementation);
 
        UnixFile.closedir = function closedir(fd) {
          // Detach the finalizer and call |_close_dir|.
          return fd.dispose();
        };
 
-       UnixFile.free =
-         libc.declare("free", ctypes.default_abi,
-                       /*return*/ ctypes.void_t,
-                       /*ptr*/    ctypes.voidptr_t);
+       {
+         // Symbol free() is special.
+         // We override the definition of free() on several platforms.
+         let default_lib = null;
+         try {
+           // On platforms for which we override free(), nspr defines
+           // a special library name "a.out" that will resolve to the
+           // correct implementation free().
+           default_lib = ctypes.open("a.out");
+         } catch (ex) {
+           // On other platforms, well, use the regular version of free.
+           default_lib = libc;
+         }
+
+         UnixFile.free =
+           default_lib.declare("free", ctypes.default_abi,
+             /*return*/ ctypes.void_t,
+             /*ptr*/    ctypes.voidptr_t);
+       }
 
        // Other functions
        UnixFile.access =
          declareFFI("access", ctypes.default_abi,
                     /*return*/ Types.negativeone_or_nothing,
                     /*path*/   Types.path,
                     /*mode*/   Types.int);