8#ifndef PXR_ARCH_MALLOC_HOOK_H
9#define PXR_ARCH_MALLOC_HOOK_H
14#include "pxr/arch/pxr.h"
15#include "pxr/arch/api.h"
20ARCH_NAMESPACE_OPEN_SCOPE
69 bool Initialize(
void* (*mallocWrapper)(
size_t,
const void*),
70 void* (*reallocWrapper)(
void*,
size_t,
const void*),
71 void* (*memalignWrapper)(
size_t,
size_t,
const void*),
72 void (*freeWrapper)(
void*,
const void*),
91 return (*_underlyingMallocFunc)(nBytes);
102 return (*_underlyingReallocFunc)(ptr, nBytes);
113 return (*_underlyingMemalignFunc)(alignment, nBytes);
124 (*_underlyingFreeFunc)(ptr);
132 void* (*_underlyingMallocFunc)(size_t);
133 void* (*_underlyingReallocFunc)(
void*, size_t);
134 void* (*_underlyingMemalignFunc)(size_t, size_t);
135 void (*_underlyingFreeFunc)(
void*);
138ARCH_NAMESPACE_CLOSE_SCOPE
Override default malloc() functionality.
Definition mallocHook.h:55
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.
void * Memalign(size_t alignment, size_t nBytes)
Call the original system memalign() function.
Definition mallocHook.h:112
void * Malloc(size_t nBytes)
Call the original system malloc() function.
Definition mallocHook.h:90
void Free(void *ptr)
Call the original system free() function.
Definition mallocHook.h:123
bool IsInitialized()
Return true if *this has been (successfully) initialized.
void * Realloc(void *ptr, size_t nBytes)
Call the original system realloc() function.
Definition mallocHook.h:101
bool ArchIsStlAllocatorOff()
Return true if the C++ STL allocator was requested to be turned off.
bool ArchIsPtmallocActive()
Return true if ptmalloc is being used as the memory allocator.