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 name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows">
6<META http-equiv="Content-Style-Type" content="text/css">
7<TITLE>OS_InitAlloc</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">OS_InitAlloc <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1>
12<H2>Syntax</H2>
13<DL>
14  <DD>
15  <PRE><CODE>#include &lt;nitro/os.h&gt;</CODE></PRE>
16  <PRE><CODE>void* OS_InitAlloc( OSArenaId id, void* arenaStart, void* arenaEnd, int maxHeaps );
17  </CODE></PRE>
18</DL>
19<H2>Arguments</H2>
20<TABLE border="1" width="100%">
21  <TBODY>
22    <TR>
23      <TD width="13%"><EM><STRONG>id</STRONG></EM></TD>
24      <TD width="87%">The arena ID of the arena for which you will initialize the memory allocation system.</TD>
25    </TR>
26    <TR>
27      <TD><B><I>arenaStart</I></B></TD>
28      <TD>Address of the arena's lower boundary</TD>
29    </TR>
30    <TR>
31      <TD><B><I>arenaEnd</I></B></TD>
32      <TD>Address of the arena's upper boundary</TD>
33    </TR>
34    <TR>
35      <TD><B><I>maxHeap</I></B></TD>
36      <TD>The maximum heap number that can be reserved in that arena.</TD>
37    </TR>
38  </TBODY>
39</TABLE>
40<H2>Return Values</H2>
41<P>After acquiring the region for heap information at the start of the arena, this function returns the arena's actual 32-byte aligned, lower boundary address.  </P>
42<H2>Description</H2>
43<P>Initializes memory allocation.</P>
44<P>This function must be called first before creating a heap that is specified by the arena ID <em><strong><code>id</code></strong></em>. For more information about the arena ID value, see <A href="../arena/OS_InitArena.html"><CODE>OS_InitArena</CODE></A>.</P>
45<P>An information region for heaps is reserved at the beginning of the arena. The address that is returned after <a href="OS_InitAlloc.html"><code>OS_InitAlloc</code></a> is the arena's lower boundary address (start address) after the region has been reserved. Therefore, set and correct using the <CODE>OS_Set*ArenaLo</CODE> function.</P>
46
47<BLOCKQUOTE>Example: <BR>
48<PRE>
49void* nstart;
50
51// In main memory, initialize all of the arena for the heap region
52// Declares that the maximum number of the heap is 3
53nstart = OS_InitAlloc( OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 3 );
54
55// Lower boundary address of the arena
56OS_SetMainArenaLo( nstart );</PRE>
57</BLOCKQUOTE>
58
59<P>To start over with the setting, it is necessary to clear the memory allocation system information from arena by using the <a href="OS_ClearAlloc.html">OS_ClearAlloc</a> function.</P>
60<H2>See Also</H2>
61<P><A href="../arena/OS_SetArenaLo.html"><code>OS_SetArenaLo</code></A>, <A href="OS_CreateHeap.html"><code>OS_CreateHeap</code></A>, <a href="OS_ClearAlloc.html"><code>OS_ClearAlloc</code></a></P>
62<H2>Revision History</H2>
63<P>2004/08/30 Added description for <CODE>OS_ClearAlloc</CODE>.<BR>2004/07/06 Added an example.<BR>2004/01/06 Initial version. </P>
64<hr><p>CONFIDENTIAL</p></body>
65</HTML>