1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META http-equiv="Content-Style-Type" content="text/css"> 6<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 8.0.0.0 for Windows"> 7<TITLE>The Memory Allocator</TITLE> 8<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css"> 9</HEAD> 10<BODY> 11 12<H1>The Memory Allocator</H1> 13 14<H2>Introduction</H2> 15<p> 16Some of the NintendoWare libraries perform necessary memory allocation for themselves. While these libraries require the dynamic allocation of memory within the library, any method of memory resource management can be used. It's therefore preferable to avoid any dependence on a particular memory management library. 17</p> 18<p> 19A memory allocator mechanism has therefore been introduced to address this. The memory allocator is used in conjunction with a specific memory management library. The memory allocator provides only the functionality for allocating and deallocates memory while the actual operations are carried out by calling the memory management library functionality. The library receives the memory allocator, and allocates and deallocates memory through the allocator. Therefore, the library is not dependent on a specific memory management library. 20</p> 21 22<H2>Initializing Memory Allocators</H2> 23<p> 24Before using a memory allocator, it must be initialized. The memory allocator holds the required information in a structure named <CODE>MEMAllocator</CODE>, and is initialized by passing the pointer to this structure using the initialization function. There are four types of initialization functions, and they correspond to the three MEM library heaps and one RevolutionSDK OS heap. The initialization functions are described below. 25</p> 26 27<TABLE border="1"> 28<CAPTION>Functions for Initializing the Memory Allocator</CAPTION> 29 <TR> 30<TH>function</TH> 31<TH>features</TH> 32 </TR> 33 <TR> 34<TD><A HREF="./Allocator/MEMInitAllocatorForExpHeap.html"><CODE>MEMInitAllocatorForExpHeap()</CODE></A></TD> 35<TD>Initializes the allocator to allocate and deallocate memory from the expanded heap.</TD> 36 </TR> 37 <TR> 38<TD><A HREF="./Allocator/MEMInitAllocatorForFrmHeap.html"><CODE>MEMInitAllocatorForFrmHeap()</CODE></A></TD> 39<TD>Initializes the allocator to allocate and deallocate memory from the frame heap.</TD> 40 </TR> 41 <TR> 42<TD><A HREF="./Allocator/MEMInitAllocatorForUnitHeap.html"><CODE>MEMInitAllocatorForUnitHeap()</CODE></A></TD> 43<TD>Initializes the allocator to allocate and deallocate memory from the unit heap.</TD> 44 </TR> 45 <TR> 46<TD><A HREF="./Allocator/MEMInitAllocatorForOSHeap.html"><CODE>MEMInitAllocatorForOSHeap()</CODE></A></TD> 47<TD>Initializes the allocator to allocate and deallocate memory from the RevolutionSDK OS heap.</TD> 48 </TR> 49</TABLE> 50<p> 51Regardless of which initialization function is used, the corresponding heap must be created before the function is called. 52</p> 53 54<H2>Memory Allocator Functions</H2> 55<p> 56There are two memory allocator functions; one for allocating and one for deallocating memory. The actual behavior depends on the type of the memory management library associated with the function. The functions for allocating and deallocating memory blocks are described in the table below. 57</p> 58 59<TABLE border="1"> 60<CAPTION>Functions for Allocating and Deallocating Memory Blocks</CAPTION> 61 <TR> 62<TH>function</TH> 63<TH>features</TH> 64 </TR> 65 <TR> 66<TD><A HREF="./Allocator/MEMAllocFromAllocator.html"><CODE>MEMAllocFromAllocator()</CODE></A></TD> 67<TD>Allocates memory blocks from the allocator.</TD> 68 </TR> 69 <TR> 70<TD><A HREF="./Allocator/MEMFreeToAllocator.html"><CODE>MEMFreeToAllocator()</CODE></A></TD> 71<TD>Returns the memory block to the allocator and deallocates the memory block.</TD> 72 </TR> 73</TABLE> 74 75<H2>Associating Unique Memory Management Libraries and Memory Allocators</H2> 76<p> 77Situations may arise where you want to use a unique memory management library with a memory allocator, or to change the behavior of a conventionally prepared memory allocator. You can do so by uniquely implementing the memory allocator. Refer to the memory allocator source for instructions on unique implementation. 78</p> 79 80<H2>Revision History</H2> 81<P>2006/03/01 Initial version.</P> 82<hr> 83<P>CONFIDENTIAL</p> 84</BODY> 85</HTML> 86