7#ifndef PXR_BASE_ARCH_MALLOC_HOOK_H
8#define PXR_BASE_ARCH_MALLOC_HOOK_H
15#include "pxr/base/arch/api.h"
20PXR_NAMESPACE_OPEN_SCOPE
72 bool Initialize(
void* (*mallocWrapper)(
size_t,
const void*),
73 void* (*reallocWrapper)(
void*,
size_t,
const void*),
74 void* (*memalignWrapper)(
size_t,
size_t,
const void*),
75 void (*freeWrapper)(
void*,
const void*),
94 return (*_underlyingMallocFunc)(nBytes);
105 return (*_underlyingReallocFunc)(ptr, nBytes);
116 return (*_underlyingMemalignFunc)(alignment, nBytes);
127 (*_underlyingFreeFunc)(ptr);
135 void* (*_underlyingMallocFunc)(size_t);
136 void* (*_underlyingReallocFunc)(
void*, size_t);
137 void* (*_underlyingMemalignFunc)(size_t, size_t);
138 void (*_underlyingFreeFunc)(
void*);
141PXR_NAMESPACE_CLOSE_SCOPE
Override default malloc() functionality.
ARCH_API void * Malloc(size_t nBytes)
Call the original system malloc() function.
ARCH_API void * Memalign(size_t alignment, size_t nBytes)
Call the original system memalign() function.
ARCH_API bool IsInitialized()
Return true if *this has been (successfully) initialized.
ARCH_API void Free(void *ptr)
Call the original system free() function.
ARCH_API bool Initialize(void *(*mallocWrapper)(size_t, const void *), void *(*reallocWrapper)(void *, size_t, const void *), void *(*memalignWrapper)(size_t, size_t, const void *), void(*freeWrapper)(void *, const void *), std::string *errMsg)
Initialize hooks.
ARCH_API void * Realloc(void *ptr, size_t nBytes)
Call the original system realloc() function.
ARCH_API bool ArchIsStlAllocatorOff()
Return true if the C++ STL allocator was requested to be turned off.
ARCH_API bool ArchIsPtmallocActive()
Return true if ptmalloc is being used as the memory allocator.