Jenkins Software

Custom Memory Management
Override new, delete, malloc, free, and realloc

Users wishing to provide custom memory management functions can do so via RakMemoryOverride.cpp.

There are 3 global pointers defined in this file, with predefined defaults:

void* (*rakMalloc) (size_t size) = RakMalloc;
void* (*rakRealloc) (void *p, size_t size) = RakRealloc;
void (*rakFree) (void *p) = RakFree;

To override, simply set the values of these variables to something else.

For example, to override malloc, you may write:

#include "RakMemoryOverride.h"

void *MyMalloc(size_t size)
{
return malloc(size);
}

int main()
{
rakMalloc=MyMalloc;
// ...
}

Then edit the file RakNetDefinesOverrides.h and add

#define _USE_RAK_MEMORY_OVERRIDE 1

Alternatively, edit RakNetDefines.h _USE_RAK_MEMORY_OVERRIDE

See Also

Index
NetworkIDObject