Main Page   Modules   Alphabetical List   Data Structures   Data Fields  

Memory & File Interfaces
[Initialization & Resource Management]


Data Structures

struct  RwMemoryFunctions

Defines

#define RwMalloc(_s, _h)   ((RWSRCGLOBAL(memoryFuncs).rwmalloc)((_s), (_h)))
#define RwFree(_p)   ((RWSRCGLOBAL(memoryFuncs).rwfree)((_p)))
#define RwCalloc(_n, _s, _h)   ((RWSRCGLOBAL(memoryFuncs).rwcalloc)((_n), (_s), (_h)))
#define RwRealloc(_p, _s, _h)   ((RWSRCGLOBAL(memoryFuncs).rwrealloc)((_p),(_s), (_h)))
#define RwMemoryHintGetChunkID(_h)   ((_h) & 0xFFFF)
#define RwMemoryHintGetDuration(_h)   ((_h) & rwMEMHINTDUR_MASK)
#define RwMemoryHintGetFlags(_h)   ((_h) & rwMEMHINTFLAG_MASK)

Enumerations

enum  RwMemoryHintFlag { rwMEMHINTFLAG_RESIZABLE = 0x01000000, rwMEMHINTFLAG_MASK = 0xFF000000, rwMEMHINTFLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT }
enum  RwMemoryHintDuration {
  rwMEMHINTDUR_NADURATION = 0x00000000, rwMEMHINTDUR_FUNCTION = 0x00010000, rwMEMHINTDUR_FRAME = 0x00020000, rwMEMHINTDUR_EVENT = 0x00030000,
  rwMEMHINTDUR_GLOBAL = 0x00040000, rwMEMHINTDUR_MASK = 0x00FF0000, rwMEMHINTDURFORCEENUMSIZEINT = RWFORCEENUMSIZEINT
}

Functions

const RwCharRwMemoryGetLastAllocFile (void)
RwUInt32 RwMemoryGetLastAllocLine (void)
RwMemoryFunctionsRwOsGetMemoryInterface (void)

Detailed Description

Operating System

Define Documentation

#define RwCalloc _n,
_s,
_h       ((RWSRCGLOBAL(memoryFuncs).rwcalloc)((_n), (_s), (_h)))
 

RwCalloc(_n, _s, _h) is a macro that calls the currently registered RwCalloc function. You can access all registered memory functions through an RwOsGetMemoryInterface() call which returns a pointer to an RwMemoryFunctions structure. You can also override the default RenderWare Graphics functions by passing a structure populated with your own RwMemoryFunctions structure to RwEngineInit().

For RWDEBUG applications, the default RwCalloc records the file and line on which it was called. These records are shared between RwMalloc and RwRealloc, and does not store any additional history. To retrieve the last file and line, use RwMemoryGetLastAllocFile and RwMemoryGetLastAllocLine.

See also:
RwMemoryFunctions for more specific function documentation.

#define RwFree _p       ((RWSRCGLOBAL(memoryFuncs).rwfree)((_p)))
 

RwFree(_p) is a macro that calls the currently registered RwFree function. You can access all registered memory functions through an RwOsGetMemoryInterface() call which returns a pointer to an RwMemoryFunctions structure. You can also override the default RenderWare Graphics functions by passing a structure populated with your own RwMemoryFunctions structure to RwEngineInit().

See also:
RwMemoryFunctions for more specific function documentation.

#define RwMalloc _s,
_h       ((RWSRCGLOBAL(memoryFuncs).rwmalloc)((_s), (_h)))
 

RwMalloc(_s, _h) is a macro that calls the currently registered RwMalloc function. You can access all registered memory functions through an RwOsGetMemoryInterface() call which returns a pointer to an RwMemoryFunctions structure. You can also override the default RenderWare Graphics functions by passing a structure populated with your own RwMemoryFunctions structure to RwEngineInit().

For RWDEBUG applications, the default RwMalloc records the file and line on which it was called. These records are shared between RwCalloc and RwRealloc, and does not store any additional history. To retrieve the last file and line, use RwMemoryGetLastAllocFile and RwMemoryGetLastAllocLine.

See also:
RwMemoryFunctions for more specific function documentation.

#define RwMemoryHintGetChunkID _h       ((_h) & 0xFFFF)
 

Macro for extracting chunkID from a hint. This is the id of either the object for which a memory request came, or of the module a call for allocation belongs to. Refer to RwCorePluginID for a list of all object IDs and to RwEngine, RwCriterionCoreID and RwCriterionWorldID for a list of all module IDs. Refer to RwMemoryFunctions for more details about the hints.

#define RwMemoryHintGetDuration _h       ((_h) & rwMEMHINTDUR_MASK)
 

Macro for extracting duration from a hint. Refer to RwMemoryFunctions for more details about the hints.

See also:
RwMemoryHintDuration

#define RwMemoryHintGetFlags _h       ((_h) & rwMEMHINTFLAG_MASK)
 

Macro for extracting flags from a hint. Refer to RwMemoryFunctions for more details about the hints.

See also:
RwMemoryHintFlag

#define RwRealloc _p,
_s,
_h       ((RWSRCGLOBAL(memoryFuncs).rwrealloc)((_p),(_s), (_h)))
 

RwRealloc(_p, _s, _h) is a macro that calls the currently registered RwRealloc function. You can access all registered memory functions through an RwOsGetMemoryInterface() call which returns a pointer to an RwMemoryFunctions structure. You can also override the default RenderWare Graphics functions by passing a structure populated with your own RwMemoryFunctions structure to RwEngineInit().

For RWDEBUG applications, the default RwRealloc records the file and line on which it was called. These records are shared between RwMalloc and RwCalloc, and does not store any additional history. To retrieve the last file and line, use RwMemoryGetLastAllocFile and RwMemoryGetLastAllocLine.

See also:
RwMemoryFunctions for more specific function documentation.


Enumeration Type Documentation

enum RwMemoryHintDuration
 

This type represents the duration of a memory.

Enumeration values:
rwMEMHINTDUR_FUNCTION  Is used for allocating some temporary memory which will be freed inside the function scope.
rwMEMHINTDUR_FRAME  Is used for per frame memory allocations.
rwMEMHINTDUR_EVENT  Is used for allocations which persist for longer than per frame, but are not global. This can be per level or per event.
rwMEMHINTDUR_GLOBAL  Is used for all global allocations, happening on and before RwEngineStart() and which are freed on and after RwEngineStop()

enum RwMemoryHintFlag
 

This type represents the memory hint flags.

Enumeration values:
rwMEMHINTFLAG_RESIZABLE  Indicates that memory being allocated will potentially be resized with calls to RwRealloc


Function Documentation

const RwChar* RwMemoryGetLastAllocFile void   
 

RwMemoryGetLastAllocFile is a function available only in an RWDEBUG SDK, that retrieves the value of the C preprocessor symbol __FILE__ for the most recent call to the default RwMalloc, RwCalloc or RwRealloc.

This function does not exist in non-RWDEBUG SDK, so preprocessor predication should be used in an application to avoid compilation errors.

Returns:
Pointer to RwChar containing the last recorded __FILE__ from an RwMalloc, RwCalloc or RwRealloc.

RwUInt32 RwMemoryGetLastAllocLine void   
 

RwMemoryGetLastAllocLine is a function available only in an RWDEBUG SDK, that retrieves the value of the C preprocessor symbol __LINE__ for the most recent call to the default RwMalloc, RwCalloc or RwRealloc.

This function does not exist in non-RWDEBUG SDK, so preprocessor predication should be used in an application to avoid compilation errors.

Returns:
RwUInt32 containing the last recorded __LINE__ from an RwMalloc, RwCalloc or RwRealloc.

RwMemoryFunctions* RwOsGetMemoryInterface void   
 

RwOsGetMemoryInterface is used to retrieve the memory functions used by RenderWare. The application can install any alternative interface that is compliant with RenderWare functions.

If an application wishes to completely overload the memory interface then this can be achieved via the RwEngineInit API function which guarantees that the overload takes place before any memory allocation. The memory function pointers should not be manipulated directly.

Note that since RenderWare allocates and frees memory in an asynchronous fashion it is not possible to install a completely different memory handler once the library has been initialized. It is, however, possible to install a daisy chained handler that gathers statistics before calling the default.

Returns:
Returns pointer to a RwMemoryFunctions value containing pointers to memory access functions. The elements of this structure may be modified directly to install an alternative memory interface.
See also:
RwEngineInit, RwMemoryFunctions.


Criterion Software © 1993-2004 Criterion Software Limited. All rights reserved. Built Thu Feb 12 13:46:51 2004. Send Feedback