Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Memory.h File Reference

Go to the source code of this file.

Macros

#define JPH_INTERNAL_DEFAULT_ALLOCATE(size)
 
#define JPH_INTERNAL_DEFAULT_FREE(pointer)
 
#define JPH_OVERRIDE_NEW_DELETE
 Macro to override the new and delete functions.
 

Typedefs

using AllocateFunction = void *(*)(size_t inSize)
 Normal memory allocation, must be at least 8 byte aligned on 32 bit platform and 16 byte aligned on 64 bit platform.
 
using ReallocateFunction = void *(*)(void *inBlock, size_t inOldSize, size_t inNewSize)
 Reallocate memory. inBlock can be nullptr in which case it must behave as a memory allocation.
 
using FreeFunction = void (*)(void *inBlock)
 Free memory. inBlock can be nullptr in which case it must do nothing.
 
using AlignedAllocateFunction = void *(*)(size_t inSize, size_t inAlignment)
 Aligned memory allocation.
 
using AlignedFreeFunction = void (*)(void *inBlock)
 Free aligned memory. inBlock can be nullptr in which case it must do nothing.
 

Functions

JPH_EXPORT void RegisterDefaultAllocator ()
 Register platform default allocation / free functions.
 

Variables

JPH_EXPORT AllocateFunction Allocate
 
JPH_EXPORT ReallocateFunction Reallocate
 
JPH_EXPORT FreeFunction Free
 
JPH_EXPORT AlignedAllocateFunction AlignedAllocate
 
JPH_EXPORT AlignedFreeFunction AlignedFree
 

Macro Definition Documentation

◆ JPH_INTERNAL_DEFAULT_ALLOCATE

#define JPH_INTERNAL_DEFAULT_ALLOCATE ( size)
Value:
JPH::Allocate(size)

◆ JPH_INTERNAL_DEFAULT_FREE

#define JPH_INTERNAL_DEFAULT_FREE ( pointer)
Value:
JPH::Free(pointer)

◆ JPH_OVERRIDE_NEW_DELETE

#define JPH_OVERRIDE_NEW_DELETE
Value:
JPH_INLINE void *operator new (size_t inCount) { return JPH_INTERNAL_DEFAULT_ALLOCATE(inCount); } \
JPH_INLINE void operator delete (void *inPointer) noexcept { JPH_INTERNAL_DEFAULT_FREE(inPointer); } \
JPH_INLINE void *operator new[] (size_t inCount) { return JPH_INTERNAL_DEFAULT_ALLOCATE(inCount); } \
JPH_INLINE void operator delete[] (void *inPointer) noexcept { JPH_INTERNAL_DEFAULT_FREE(inPointer); } \
JPH_INLINE void *operator new (size_t inCount, std::align_val_t inAlignment) { return JPH::AlignedAllocate(inCount, static_cast<size_t>(inAlignment)); } \
JPH_INLINE void operator delete (void *inPointer, [[maybe_unused]] std::align_val_t inAlignment) noexcept { JPH::AlignedFree(inPointer); } \
JPH_INLINE void *operator new[] (size_t inCount, std::align_val_t inAlignment) { return JPH::AlignedAllocate(inCount, static_cast<size_t>(inAlignment)); } \
JPH_INLINE void operator delete[] (void *inPointer, [[maybe_unused]] std::align_val_t inAlignment) noexcept { JPH::AlignedFree(inPointer); } \
JPH_INLINE void *operator new ([[maybe_unused]] size_t inCount, void *inPointer) noexcept { return inPointer; } \
JPH_INLINE void operator delete ([[maybe_unused]] void *inPointer, [[maybe_unused]] void *inPlace) noexcept { /* Do nothing */ } \
JPH_INLINE void *operator new[] ([[maybe_unused]] size_t inCount, void *inPointer) noexcept { return inPointer; } \
JPH_INLINE void operator delete[] ([[maybe_unused]] void *inPointer, [[maybe_unused]] void *inPlace) noexcept { /* Do nothing */ }
#define JPH_INTERNAL_DEFAULT_FREE(pointer)
Definition Memory.h:45
#define JPH_INTERNAL_DEFAULT_ALLOCATE(size)
Definition Memory.h:44

Macro to override the new and delete functions.

Typedef Documentation

◆ AlignedAllocateFunction

using AlignedAllocateFunction = void *(*)(size_t inSize, size_t inAlignment)

Aligned memory allocation.

◆ AlignedFreeFunction

using AlignedFreeFunction = void (*)(void *inBlock)

Free aligned memory. inBlock can be nullptr in which case it must do nothing.

◆ AllocateFunction

using AllocateFunction = void *(*)(size_t inSize)

Normal memory allocation, must be at least 8 byte aligned on 32 bit platform and 16 byte aligned on 64 bit platform.

◆ FreeFunction

using FreeFunction = void (*)(void *inBlock)

Free memory. inBlock can be nullptr in which case it must do nothing.

◆ ReallocateFunction

using ReallocateFunction = void *(*)(void *inBlock, size_t inOldSize, size_t inNewSize)

Reallocate memory. inBlock can be nullptr in which case it must behave as a memory allocation.

Function Documentation

◆ RegisterDefaultAllocator()

JPH_EXPORT void RegisterDefaultAllocator ( )

Register platform default allocation / free functions.

Variable Documentation

◆ AlignedAllocate

JPH_EXPORT AlignedAllocateFunction AlignedAllocate
extern

◆ AlignedFree

JPH_EXPORT AlignedFreeFunction AlignedFree
extern

◆ Allocate

JPH_EXPORT AllocateFunction Allocate
extern

◆ Free

JPH_EXPORT FreeFunction Free
extern

◆ Reallocate

JPH_EXPORT ReallocateFunction Reallocate
extern