Recast Navigation
Navigation-mesh Toolset for Games
RecastAlloc.h File Reference
#include "RecastAssert.h"
#include <stdlib.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  rcNewTag
 An implementation of operator new usable for placement new. More...
 
class  rcVectorBase< T, H >
 Variable-sized storage type. More...
 
class  rcTempVector< T >
 
class  rcPermVector< T >
 
class  rcIntArray
 Legacy class. Prefer rcVector<int>. More...
 
class  rcScopedDelete< T >
 A simple helper class used to delete an array when it goes out of scope. More...
 

Macros

#define RC_SIZE_MAX   INTPTR_MAX
 
#define rcLikely(x)   (x)
 Macros to hint to the compiler about the likeliest branch. More...
 
#define rcUnlikely(x)   (x)
 

Typedefs

typedef void *() rcAllocFunc(size_t size, rcAllocHint hint)
 A memory allocation function. More...
 
typedef void() rcFreeFunc(void *ptr)
 A memory deallocation function. More...
 
typedef intptr_t rcSizeType
 Signed to avoid warnings when comparing to int loop indexes, and common error with comparing to zero. More...
 

Enumerations

enum  rcAllocHint { RC_ALLOC_PERM , RC_ALLOC_TEMP }
 Provides hint values to the memory allocator on how long the memory is expected to be used. More...
 

Functions

void rcAllocSetCustom (rcAllocFunc *allocFunc, rcFreeFunc *freeFunc)
 Sets the base custom allocation functions to be used by Recast. More...
 
void * rcAlloc (size_t size, rcAllocHint hint)
 Allocates a memory block. More...
 
void rcFree (void *ptr)
 Deallocates a memory block. More...
 
void * operator new (size_t, const rcNewTag &, void *p)
 
void operator delete (void *, const rcNewTag &, void *)
 

Macro Definition Documentation

◆ RC_SIZE_MAX

#define RC_SIZE_MAX   INTPTR_MAX

◆ rcLikely

#define rcLikely (   x)    (x)

Macros to hint to the compiler about the likeliest branch.

Please add a benchmark that demonstrates a performance improvement before introducing use cases.

◆ rcUnlikely

#define rcUnlikely (   x)    (x)

Typedef Documentation

◆ rcAllocFunc

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

A memory allocation function.

See also
rcAllocSetCustom

◆ rcFreeFunc

typedef void() rcFreeFunc(void *ptr)

A memory deallocation function.

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

◆ rcSizeType

typedef intptr_t rcSizeType

Signed to avoid warnings when comparing to int loop indexes, and common error with comparing to zero.

MSVC2010 has a bug where ssize_t is unsigned (!!!).

Enumeration Type Documentation

◆ rcAllocHint

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.

Function Documentation

◆ operator delete()

void operator delete ( void *  ,
const rcNewTag ,
void *   
)
inline

◆ operator new()

void* operator new ( size_t  ,
const rcNewTag ,
void *  p 
)
inline

◆ rcAlloc()

void* rcAlloc ( size_t  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

◆ rcAllocSetCustom()

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

◆ rcFree()

void rcFree ( void *  ptr)

Deallocates a memory block.

If ptr is NULL, this does nothing.

Warning
This function leaves the value of ptr unchanged. So it still points to the same (now invalid) location, and not to null.
Parameters
[in]ptrA pointer to a memory block previously allocated using rcAlloc.
See also
rcAlloc, rcAllocSetCustom