From 8d4965cabcb41ab0ca804298807168d70e5da92b Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Mon, 2 May 2016 12:22:28 -0700 Subject: [PATCH] Don't try to use the malloc_usable_size portability implementation if we have JEMalloc 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 | 2 ++ folly/portability/Malloc.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/folly/portability/Malloc.cpp b/folly/portability/Malloc.cpp index 402ee099..9baecb38 100755 --- a/folly/portability/Malloc.cpp +++ b/folly/portability/Malloc.cpp @@ -16,6 +16,7 @@ #include +#ifndef USE_JEMALLOC #if defined(__APPLE__) && !defined(FOLLY_HAVE_MALLOC_USABLE_SIZE) #include @@ -27,3 +28,4 @@ extern "C" size_t malloc_usable_size(void* addr) { return _msize(addr); } #endif +#endif diff --git a/folly/portability/Malloc.h b/folly/portability/Malloc.h index e310dff9..32c1ab33 100755 --- a/folly/portability/Malloc.h +++ b/folly/portability/Malloc.h @@ -18,6 +18,11 @@ #include +#ifdef USE_JEMALLOC +// JEMalloc provides it's own implementation of +// malloc_usable_size, and that's what we should be using. +#include +#else #ifndef __APPLE__ #include #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 -- 2.34.1