TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RecastAlloc.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  rcIntArray
 A simple dynamic array of integers. More...
 
class  rcScopedDelete< T >
 

Typedefs

typedef void *( rcAllocFunc )(int size, rcAllocHint hint)
 A memory allocation function. More...
 
typedef void( rcFreeFunc )(void *ptr)
 

Enumerations

enum  rcAllocHint { RC_ALLOC_PERM, RC_ALLOC_TEMP }
 

Functions

void rcAllocSetCustom (rcAllocFunc *allocFunc, rcFreeFunc *freeFunc)
 
void * rcAlloc (int size, rcAllocHint hint)
 
void rcFree (void *ptr)
 

Typedef Documentation

typedef void*( rcAllocFunc)(int size, rcAllocHint hint)

A memory allocation function.

See also
rcAllocSetCustom
typedef void( rcFreeFunc)(void *ptr)

A memory deallocation function.

Parameters
[in]ptrA pointer to a memory block previously allocated using rcAllocFunc.
See also
rcAllocSetCustom

Enumeration Type Documentation

Provides hint values to the memory allocator on how long the memory is expected to be used.

Enumerator
RC_ALLOC_PERM 

Memory will persist after a function call.

RC_ALLOC_TEMP 

Memory used temporarily within a function.

25 {
28 };
Memory will persist after a function call.
Definition: RecastAlloc.h:26
Memory used temporarily within a function.
Definition: RecastAlloc.h:27

Function Documentation

void* rcAlloc ( int  size,
rcAllocHint  hint 
)

Allocates a memory block.

Parameters
[in]sizeThe size, in bytes of memory, to allocate.
[in]hintA hint to the allocator on how long the memory is expected to be in use.
Returns
A pointer to the beginning of the allocated memory block, or null if the allocation failed.
See also
rcFree
rcAllocSetCustom
45 {
46  return sRecastAllocFunc(size, hint);
47 }
static rcAllocFunc * sRecastAllocFunc
Definition: RecastAlloc.cpp:33

+ Here is the caller graph for this function:

void rcAllocSetCustom ( rcAllocFunc allocFunc,
rcFreeFunc freeFunc 
)

Sets the base custom allocation functions to be used by Recast.

Parameters
[in]allocFuncThe memory allocation function to be used by rcAlloc
[in]freeFuncThe memory de-allocation function to be used by rcFree
See also
rcAlloc, rcFree
38 {
39  sRecastAllocFunc = allocFunc ? allocFunc : rcAllocDefault;
40  sRecastFreeFunc = freeFunc ? freeFunc : rcFreeDefault;
41 }
static rcFreeFunc * sRecastFreeFunc
Definition: RecastAlloc.cpp:34
static void rcFreeDefault(void *ptr)
Definition: RecastAlloc.cpp:28
static void * rcAllocDefault(int size, rcAllocHint)
Definition: RecastAlloc.cpp:23
static rcAllocFunc * sRecastAllocFunc
Definition: RecastAlloc.cpp:33

+ Here is the call graph for this function:

void rcFree ( void *  ptr)

Deallocates a memory block.

Parameters
[in]ptrA pointer to a memory block previously allocated using rcAlloc.
See also
rcAlloc
Warning
This function leaves the value of ptr unchanged. So it still points to the same (now invalid) location, and not to null.
See also
rcAllocSetCustom
56 {
57  if (ptr)
58  sRecastFreeFunc(ptr);
59 }
static rcFreeFunc * sRecastFreeFunc
Definition: RecastAlloc.cpp:34

+ Here is the caller graph for this function: