Skip to content

Commit

Permalink
Hide jemalloc aligned allocation functions into .cc (facebook#4025)
Browse files Browse the repository at this point in the history
Summary:
so they could be overriden
Closes facebook#4025

Differential Revision: D8526287

Pulled By: siying

fbshipit-source-id: 9537b299dc907b4d1eeaf77a8784b13cb058280d
  • Loading branch information
yuslepukhin authored and facebook-github-bot committed Jun 20, 2018
1 parent 28a9d89 commit 61d69d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 2 additions & 7 deletions port/win/port_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions port/win/win_jemalloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <stdexcept>
#include "jemalloc/jemalloc.h"
#include "port/win/port_win.h"

#if defined(ZSTD) && defined(ZSTD_STATIC_LINKING_ONLY)
#include <zstd.h>
Expand All @@ -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) {
Expand Down

0 comments on commit 61d69d4

Please sign in to comment.