Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TCMALLOC_NO_NEW_DELETE_OVERRIDES/TCMALLOC_NO_C_ALLOC_OVERRIDES #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tcmalloc/libc_override_gcc_and_weak.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#define TCMALLOC_ALIAS(tc_fn) \
__attribute__((alias(#tc_fn), visibility("default")))

#ifndef TCMALLOC_NO_NEW_DELETE_OVERRIDES
void* operator new(size_t size) noexcept(false)
TCMALLOC_ALIAS(TCMallocInternalNew);
void operator delete(void* p) noexcept TCMALLOC_ALIAS(TCMallocInternalDelete);
Expand Down Expand Up @@ -81,7 +82,9 @@ void operator delete[](void* p, std::align_val_t alignment,
void operator delete[](void* p, size_t size,
std::align_val_t alignemnt) noexcept
TCMALLOC_ALIAS(TCMallocInternalDeleteArraySizedAligned);
#endif // \TCMALLOC_NO_NEW_DELETE_OVERRIDES

#ifndef TCMALLOC_NO_C_ALLOC_OVERRIDES
extern "C" {
void* malloc(size_t size) noexcept TCMALLOC_ALIAS(TCMallocInternalMalloc);
void free(void* ptr) noexcept TCMALLOC_ALIAS(TCMallocInternalFree);
Expand Down Expand Up @@ -109,5 +112,6 @@ size_t malloc_size(void* p) noexcept TCMALLOC_ALIAS(TCMallocInternalMallocSize);
size_t malloc_usable_size(void* p) noexcept
TCMALLOC_ALIAS(TCMallocInternalMallocSize);
} // extern "C"
#endif // \TCMALLOC_NO_C_ALLOC_OVERRIDES

#endif // TCMALLOC_LIBC_OVERRIDE_GCC_AND_WEAK_INL_H_
3 changes: 3 additions & 0 deletions tcmalloc/tcmalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@

#include <malloc.h>
#include <stddef.h>
#include <new>

#include "absl/base/attributes.h"
#ifndef TCMALLOC_NO_NEW_DELETE_OVERRIDES
#include "tcmalloc/internal/declarations.h"
#endif

// __THROW is defined in glibc systems. It means, counter-intuitively,
// "This function will never throw an exception." It's an optional
Expand Down