Don't try to use the malloc_usable_size portability implementation if we have JEMalloc
authorChristopher Dykes <cdykes@fb.com>
Mon, 2 May 2016 19:22:28 +0000 (12:22 -0700)
committerFacebook Github Bot 3 <facebook-github-bot-3-bot@fb.com>
Mon, 2 May 2016 19:35:19 +0000 (12:35 -0700)
Summary:
This is only an issue for the OSS HHVM build on OSX, where we have JEMalloc headers included directly.
In the OSS HHVM build, we define `USE_JEMALLOC` globally if we have JEMalloc, so gate the portability implementation behind that.

Reviewed By: mzlee

Differential Revision: D3237449

fb-gh-sync-id: 07cf9b31114723ffd9f2b29cf449bee0ed8f5703
fbshipit-source-id: 07cf9b31114723ffd9f2b29cf449bee0ed8f5703

folly/portability/Malloc.cpp
folly/portability/Malloc.h

index 402ee099dde8b6eb7dff68d325df6e2562742e5e..9baecb38e226fddbac7227fe3fbf4bd7ef0f71e2 100755 (executable)
@@ -16,6 +16,7 @@
 
 #include <folly/portability/Malloc.h>
 
+#ifndef USE_JEMALLOC
 #if defined(__APPLE__) && !defined(FOLLY_HAVE_MALLOC_USABLE_SIZE)
 #include <malloc/malloc.h>
 
@@ -27,3 +28,4 @@ extern "C" size_t malloc_usable_size(void* addr) {
   return _msize(addr);
 }
 #endif
+#endif
index e310dff90a81062da6218df78fd46224673de329..32c1ab3334ec7157f2402b906b40ee3a5f1f3bd6 100755 (executable)
 
 #include <stdlib.h>
 
+#ifdef USE_JEMALLOC
+// JEMalloc provides it's own implementation of
+// malloc_usable_size, and that's what we should be using.
+#include <jemalloc/jemalloc.h>
+#else
 #ifndef __APPLE__
 #include <malloc.h>
 #endif
@@ -30,3 +35,4 @@ extern "C" size_t malloc_usable_size(void* ptr);
 #elif defined(_WIN32)
 extern "C" size_t malloc_usable_size(void* ptr);
 #endif
+#endif