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
main
Dmitri Smirnov 7 years ago committed by Facebook Github Bot
parent 28a9d8910b
commit 61d69d450d
  1. 9
      port/win/port_win.h
  2. 8
      port/win/win_jemalloc.cc

@ -244,14 +244,9 @@ extern void InitOnce(OnceType* once, void (*initializer)());
#endif #endif
#ifdef ROCKSDB_JEMALLOC #ifdef ROCKSDB_JEMALLOC
#include "jemalloc/jemalloc.h"
// Separate inlines so they can be replaced if needed // Separate inlines so they can be replaced if needed
inline void* jemalloc_aligned_alloc( size_t size, size_t alignment) { 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;
}
inline void jemalloc_aligned_free(void* p) {
je_free(p);
}
#endif #endif
inline void *cacheline_aligned_alloc(size_t size) { inline void *cacheline_aligned_alloc(size_t size) {

@ -13,6 +13,7 @@
#include <stdexcept> #include <stdexcept>
#include "jemalloc/jemalloc.h" #include "jemalloc/jemalloc.h"
#include "port/win/port_win.h"
#if defined(ZSTD) && defined(ZSTD_STATIC_LINKING_ONLY) #if defined(ZSTD) && defined(ZSTD_STATIC_LINKING_ONLY)
#include <zstd.h> #include <zstd.h>
@ -36,6 +37,13 @@ ZSTD_customMem GetJeZstdAllocationOverrides() {
// Global operators to be replaced by a linker when this file is // Global operators to be replaced by a linker when this file is
// a part of the build // 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* operator new(size_t size) {
void* p = je_malloc(size); void* p = je_malloc(size);
if (!p) { if (!p) {

Loading…
Cancel
Save