MathEngine
Home Page       Structures       File List       Functions and Macros      

MeMemoryAPI Struct Reference

Table of pointers to memory manager functions. More...

#include <MeMemory.h>

List of all members.

Public Attributes

void (* setOptions )(const struct MeMemoryOptions *const options)
 Set memory manager API options. More...

void (* getOptions )(struct MeMemoryOptions *const options)
 Get memory manager API options. More...

void (* init )(void *const arena,const size_t bytes,...)
 Initialize the memory manager. More...

void* (* create )(size_t bytes,...)
 Allocate a block of at least that given size. More...

void* (* resize )(void *block,size_t bytes,...)
 Change the size of a block, possibly moving it. More...

void (* incRef )(const void *const block)
 Increment the in-use count of a block. More...

void (* decRef )(const void *const block)
 Decrement the in-use count of a block. More...

void (* destroy )(void *const block,...)
 Reduce the in-use count of a block to zero. More...

void (* getStats )(struct MeMemoryStats *const stats)
 Obtain a copy of the usage statistics of the memory manager API. More...

void (* term )()
 Terminate memory manager API operation. More...


Detailed Description

Table of pointers to memory manager functions.

Each memory manager usable via this API will come with a set of API compliant wrapper functions, that will be packaged in a 'struct' similar to this one. At program startup copy that into the canonical one called 'MeMemoryAPI' to initialise it.

Examples:

ArraysBench.c, ArraysTest.c, and MallocTest.c.


Member Data Documentation

void *(* MeMemoryAPI::create)(size_t bytes,...)

Allocate a block of at least that given size.

If there are any options (form example for placement) then these can be specified after the size, but this will be highly unportable.

The in-use count of the newly created block will be one.

void(* MeMemoryAPI::decRef)(const void *const block)

Decrement the in-use count of a block.

This function may actually do nothing.

void(* MeMemoryAPI::destroy)(void *const block,...)

Reduce the in-use count of a block to zero.

This function may actually do nothing, for example when the memory manager does automatic reclamation via garbage collection.

void(* MeMemoryAPI::getOptions)(struct MeMemoryOptions *const options)

Get memory manager API options.

Returns the memory manager options that have been set.

void(* MeMemoryAPI::getStats)(struct MeMemoryStats *const stats)

Obtain a copy of the usage statistics of the memory manager API.

The statistics returned may be incomplete, depending on how many are supported by the memory manager itself. It can be called after setOptions and before init to

void(* MeMemoryAPI::incRef)(const void *const block)

Increment the in-use count of a block.

This function may actually do nothing.

void(* MeMemoryAPI::init)(void *const arena,const size_t bytes,...)

Initialize the memory manager.

Allows memory manager initialisation. You should first call setOptions to inform the API what kind of memory manager is desirable, and getStats to see what kind of memory arena size the API thinks that requires.

Then, if necessary, allocate that size (or something else) and pass it the allocate arena to this function.

void *(* MeMemoryAPI::resize)(void *block,size_t bytes,...)

Change the size of a block, possibly moving it.

If there are any options (form example for placement) then these can be specified after the size, but this will be highly unportable.

This function may fail as it may be unavailable under some memory managers, or the specific resizing may be impossible or unsupported. In particular resizing to a smaller size may be forbidden, or resizing to a larger one may not be feasible.

void(* MeMemoryAPI::setOptions)(const struct MeMemoryOptions *const options)

Set memory manager API options.

Use this to setup the memory manager API with hints as to what kind of memory manager and policy it should select.

void(* MeMemoryAPI::term)()

Terminate memory manager API operation.

Invoking this will often be needed in order to collect some types of statistics. It also will often check that usage of the API has been correct, e.g. that the number of calls to incRef and to decRef has been the same.


The documentation for this struct was generated from the following file:
MathEngine Utilities: Memory Manager API - Version 0.0.5 Alpha - Reference Manual generated using doxygen at Wed Oct 11 00:34:57 2000

Copyright MathEngine PLC 2000, all rights reserved.