diff --git a/gecode/support/allocator.hpp b/gecode/support/allocator.hpp index a76238fb87..2e8f437977 100644 --- a/gecode/support/allocator.hpp +++ b/gecode/support/allocator.hpp @@ -42,6 +42,14 @@ #include #endif +#ifdef GECODE_JEMALLOC_H +#include +#endif + +#ifdef GECODE_TCMALLOC_H +#include +#endif + #ifdef GECODE_ALLOCATOR namespace Gecode { namespace Support { @@ -77,15 +85,27 @@ namespace Gecode { namespace Support { } forceinline void* Allocator::alloc(size_t n) { + #ifdef GECODE_TCMALLOC_H + return tc_mallock(n); + #else return ::malloc(n); + #endif } forceinline void* Allocator::realloc(void* p, size_t n) { + #ifdef GECODE_TCMALLOC_H + return tc_realloc(p,n); + #else return ::realloc(p,n); + #endif } forceinline void Allocator::free(void* p) { + #ifdef GECODE_TCMALLOC_H + tc_free(p); + #else ::free(p); + #endif } forceinline void* Allocator::memcpy(void *d, const void *s, size_t n) {