From 61d69d450df76e8e03bd5e7b79c5bbe66905348b Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Tue, 19 Jun 2018 17:07:49 -0700 Subject: [PATCH] Hide jemalloc aligned allocation functions into .cc (#4025) Summary: so they could be overriden Closes https://github.com/facebook/rocksdb/pull/4025 Differential Revision: D8526287 Pulled By: siying fbshipit-source-id: 9537b299dc907b4d1eeaf77a8784b13cb058280d --- port/win/port_win.h | 9 ++------- port/win/win_jemalloc.cc | 8 ++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/port/win/port_win.h b/port/win/port_win.h index 6da9f955d..8a6c5aad1 100644 --- a/port/win/port_win.h +++ b/port/win/port_win.h @@ -244,14 +244,9 @@ extern void InitOnce(OnceType* once, void (*initializer)()); #endif #ifdef ROCKSDB_JEMALLOC -#include "jemalloc/jemalloc.h" // Separate inlines so they can be replaced if needed -inline void* jemalloc_aligned_alloc( size_t size, size_t alignment) { - return je_aligned_alloc(alignment, size); -} -inline void jemalloc_aligned_free(void* p) { - je_free(p); -} +void* jemalloc_aligned_alloc(size_t size, size_t alignment) ROCKSDB_NOEXCEPT; +void jemalloc_aligned_free(void* p) ROCKSDB_NOEXCEPT; #endif inline void *cacheline_aligned_alloc(size_t size) { diff --git a/port/win/win_jemalloc.cc b/port/win/win_jemalloc.cc index 51a3afc62..18caf2cba 100644 --- a/port/win/win_jemalloc.cc +++ b/port/win/win_jemalloc.cc @@ -13,6 +13,7 @@ #include #include "jemalloc/jemalloc.h" +#include "port/win/port_win.h" #if defined(ZSTD) && defined(ZSTD_STATIC_LINKING_ONLY) #include @@ -36,6 +37,13 @@ ZSTD_customMem GetJeZstdAllocationOverrides() { // Global operators to be replaced by a linker when this file is // a part of the build +void* jemalloc_aligned_alloc( size_t size, size_t alignment) ROCKSDB_NOEXCEPT { + return je_aligned_alloc(alignment, size); +} +void jemalloc_aligned_free(void* p) ROCKSDB_NOEXCEPT { + je_free(p); +} + void* operator new(size_t size) { void* p = je_malloc(size); if (!p) {