Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
XMemory.h File Reference

Set memory callbacks, memory leaks and low level allocation functions. More...

Detailed Description

Set memory callbacks, memory leaks and low level allocation functions.

#include "XMemoryMacros.h"

Go to the source code of this file.

Classes

struct  XMemoryCallback
 Defines a set of memory callback handlers that can be modified. More...
 

Macros

#define xmalloc_array(nSize, nCount)   xmalloc((nSize)*(nCount))
 
#define xfree_array(p, nCount)   xfree(p)
 
#define xnew_array(nSize, nCount)   xnew((nSize)*(nCount))
 
#define xdelete_array(p, nCount)   xdelete(p)
 

Typedefs

typedef enum XAllocType XAllocType
 
typedef void *(* mallocCallback) (size_t newSize, XAllocType type)
 Called by malloc / calloc / new operation.
 
typedef void *(* reallocCallback) (void *pointer, size_t newSize)
 Called by realloc operation.
 
typedef void(* freeCallback) (void *pointer, XAllocType type)
 Called by free / delete operation.
 
typedef struct XMemoryCallback XMemoryCallback
 

Enumerations

enum  XAllocType {
  XALLOC_UNDEFINED = 0 , XALLOC_MALLOC , XALLOC_CALLOC , XALLOC_FREE ,
  XALLOC_NEW , XALLOC_DELETE , XALLOC_MALLOC_ALIGNED , XALLOC_CALLOC_ALIGNED ,
  XALLOC_NEW_ALIGNED
}
 Defines the required allocation type provided through XMemoryCallback callback. More...
 

Functions

Main library allocators (superseed C standard allocators)
DLL_TOOLSFUNCTION voidxmalloc (size_t nSize)
 
DLL_TOOLSFUNCTION void xfree (void *p)
 
DLL_TOOLSFUNCTION voidxrealloc (void *p, size_t newSize)
 
DLL_TOOLSFUNCTION voidxcalloc (size_t numElement, size_t elementSize)
 
DLL_TOOLSFUNCTION voidxnew (size_t nSize)
 Only used by macros xNew.
 
DLL_TOOLSFUNCTION void xdelete (void *p)
 Only used by macros xDelete.
 

Variables

DLL_TOOLSFUNCTION XMemoryCallback memoryCallbackNotify
 

Enumeration Type Documentation

◆ XAllocType

Defines the required allocation type provided through XMemoryCallback callback.

Enumerator
XALLOC_MALLOC 

malloc C method

XALLOC_CALLOC 

calloc C method. Do not forget to call something equivalent to calloc that set memory to 0

XALLOC_FREE 

free C method

XALLOC_NEW 

new C++

XALLOC_DELETE 

delete C++

XALLOC_MALLOC_ALIGNED 

Not used.

XALLOC_CALLOC_ALIGNED 

Not used.

XALLOC_NEW_ALIGNED 

Not used.

Variable Documentation

◆ memoryCallbackNotify

DLL_TOOLSFUNCTION XMemoryCallback memoryCallbackNotify
extern

Use this memory callback object to receive notification on new, malloc, realloc, free, delete

Note
memoryCallbackNotify is initialized at startup.
As the static order initialization is unknown, do not use these memory function to allocate static objects.
Such objet might be allocated before XMemoryCallback constructors calls resulting in invalid callback pointer and potential crash.