PROGRAMMER'S GUIDEMemory management library
■ | Advance
Memory management library

1. 1. guide


1.1 Purpose

A library for easy memory management.

1.2 Overview

It provides various functions for allocating and freeing memory.
When freeing memory, look at both sides of the freed area and consolidate any free space.
These functions reduce the burden of memory management on the user.
Functions have a function interface that is similar to standard functions.

1.3 Calling sequence

The calling sequence for allocating and releasing memory blocks is shown below.

void sysInit ()
{
     ...     
     MEM_Init (0x6050000, 0x10000); / * Set 10000H bytes from address 6050000H to the memory management area * /
     ...
}
...
void userFunc ()
{
     Uint32 * mem_area1;
     Uint8 * mem_area2;

     ...
     mem_area1 = (Uint32 *) MEM_Malloc (4); / * Allocate 4 bytes * /
     if (mem_area1 == NULL) {
          return (ERR);
     }
     mem_area2 = (Uint8 *) MEM_Malloc (1); / * Allocate 1 byte area * /
     if (mem_area2 == NULL) {
          return (ERR);
     }
     ...
     ...
     MEM_Free (mem_area1); / * Free memory of mem_area1 * /
     ...
}


■ | Advance
PROGRAMMER'S GUIDEMemory management library
Copyright SEGA ENTERPRISES, LTD., 1997