General Info

Interface: MemManager
Files: lib/memmanager.h
Last change: 14/02/2002
Author: Luiz Henrique Shigunov
Description
Structures
Functions
  • 0x00 - Alloc - Allocate a memory chunk
  • 0x01 - AllocAlign - Allocate an aligned memory chunk
  • 0x02 - AllocClear - Allocate and clear a memory chunk
  • 0x03 - AllocPageAlign - Allocate a page aligned memory chunk
  • 0x04 - AllocPageRound - Allocate a page aligned memory chunk round up to a page size
  • 0x05 - Free - Free a memory chunk
  • 0x06 - GetMemStats - Get some statistics
  • 0x07 - GetUsableSize - Get usable size of a memory chunk
  • 0x08 - MemTrim - Trim the heap
  • 0x09 - ReAlloc - Reallocate a memory chunk keeping the same data
  • 0x0a - SetMemOption - Set a memory option
  • Description

    This page describes MemManager user interface.

    The MemManager user interface provides dinamic memory allocation to programs/libraries.

    Structures

    typedef struct {
        unsigned int totalMem;
        unsigned int allocAreas;
        unsigned int totalAreas;
        unsigned int totalAlloc;
        unsigned int totalFree;
        unsigned int trimArea;
    } MemoryStats;
    

    Where totalMem is the total space allocated from system, allocAreas is the number of areas allocated using AllocPages, totalAreas is the total space allocated using AllocPages, totalAlloc is the total allocated space, totalFree is the total free space and trimArea is the area that can be freed using MemTrim.

    0x00 - Alloc

    Syntax

    void *Alloc(unsigned int size);

    Description

    This function allocates a memory chunk of at least size bytes.

    Return value

    0x01 - AllocAlign

    Syntax

    void *AllocAlign(unsigned int align, unsigned int size);

    Description

    This function allocates a memory chunk of at least size bytes, aligned in accord with align, which must be a power of 2.

    Return value

    0x02 - AllocClear

    Syntax

    void *AllocClear(unsigned int unit, unsigned int n);

    Description

    This function allocates a memory chunk of at least unit * n bytes, with all locations set to zero.

    Return value

    0x03 - AllocPageAlign

    Syntax

    void *AllocPageAlign(unsigned int size);

    Description

    This function allocates a memory chunk of at least size bytes, aligned in a system page size.

    Return value

    0x04 - AllocPageRound

    Syntax

    void *AllocPageRound(unsigned int size);

    Description

    This function allocates a memory chunk in a way that the minimal multiple of a system page >= size bytes.

    That is, round up size to system page size and allocate a memory chunk of that size.

    Return value

    0x05 - Free

    Syntax

    void Free(void *p);

    Description

    This function frees the memory chunk p or does nothing if p is NULL.

    Return value

    Nothing.

    0x06 - GetMemStats

    Syntax

    MemoryStats GetMemStats(void);

    Description

    This function gets some memory usage statistics.

    Return value

    The memory usage statistics.

    0x07 - GetUsableSize

    Syntax

    unsigned int GetUsableSize(void *p);

    Description

    This function gets the number of bytes usable in the memory chunk p.

    This function can return more bytes usable than the one that were requested.

    Return value

    The number of bytes usable.

    0x08 - MemTrim

    Syntax

    int MemTrim(unsigned int pad);

    Description

    This function frees all but pad bytes of freed top-most memory back to the system.

    Return value

    0x09 - ReAlloc

    Syntax

    void *ReAlloc(void *p, unsigned int size);

    Description

    This function allocates a memory chunk of size that contains the same data as does chunk p up to the minimum of (size, p's size) bytes.

    The returned pointer may or may not be the same as p.

    If p is NULL, equivalent to Alloc.

    If size is 0, equivalent to Free(p).

    Return value

    0x0a - SetMemOption

    Syntax

    int SetMemOption(int option, void *value);

    Description

    This function sets option to value.

    option and value are dependent of the implementation. See the implementation docs.

    Return value