📄 memlib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/memLib.html - generated by refgen from memLib.c --> <title> memLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference : OS Libraries</i></a></p></blockquote><h1>memLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>memLib</strong> - full-featured memory partition manager </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./memLib.html#memPartOptionsSet">memPartOptionsSet</a>( )</b> - set the debug options for a memory partition<br><b><a href="./memLib.html#memalign">memalign</a>( )</b> - allocate aligned memory <br><b><a href="./memLib.html#valloc">valloc</a>( )</b> - allocate memory on a page boundary <br><b><a href="./memLib.html#memPartRealloc">memPartRealloc</a>( )</b> - reallocate a block of memory in a specified partition<br><b><a href="./memLib.html#memPartFindMax">memPartFindMax</a>( )</b> - find the size of the largest available free block<br><b><a href="./memLib.html#memOptionsSet">memOptionsSet</a>( )</b> - set the debug options for the system memory partition<br><b><a href="./memLib.html#calloc">calloc</a>( )</b> - allocate space for an array (ANSI)<br><b><a href="./memLib.html#realloc">realloc</a>( )</b> - reallocate a block of memory (ANSI)<br><b><a href="./memLib.html#cfree">cfree</a>( )</b> - free a block of memory<br><b><a href="./memLib.html#memFindMax">memFindMax</a>( )</b> - find the largest free block in the system memory partition<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides full-featured facilities for managing the allocationof blocks of memory from ranges of memory called memory partitions. Thelibrary is an extension of <b><a href="./memPartLib.html#top">memPartLib</a></b> and provides enhanced memory managementfeatures, including error handling, aligned allocation, and ANSI allocationroutines. For more information about the core memory partition management facility, see the manual entry for <b><a href="./memPartLib.html#top">memPartLib</a></b>.<p>The system memory partition is created when the kernel is initializedby <b><a href="./kernelLib.html#kernelInit">kernelInit</a>( )</b>, which is called by the root task, <b><a href="./usrConfig.html#usrRoot">usrRoot</a>( )</b>, in <b>usrConfig.c</b>.The ID of the system memory partition is stored in the global variable<b>memSysPartId</b>; its declaration is included in <b>memLib.h</b>.<p>The <b><a href="./memLib.html#memalign">memalign</a>( )</b> routine is provided for allocating memory aligned to a specifiedboundary.<p>This library includes three ANSI-compatible routines:<b><a href="./memLib.html#calloc">calloc</a>( )</b> allocates a block of memory for an array;<b><a href="./memLib.html#realloc">realloc</a>( )</b> changes the size of a specified block of memory; and<b><a href="./memLib.html#cfree">cfree</a>( )</b> returns to the free memory pool a block of memory thatwas previously allocated with <b><a href="./memLib.html#calloc">calloc</a>( )</b>.<p></blockquote><h4>ERROR OPTIONS</h4><blockquote><p>Various debug options can be selected for each partition using<b><a href="./memLib.html#memPartOptionsSet">memPartOptionsSet</a>( )</b> and <b><a href="./memLib.html#memOptionsSet">memOptionsSet</a>( )</b>. Two kinds of errors are detected: attempts to allocate more memorythan is available, and bad blocks found when memory is freed. In bothcases, the error status is returned. There are four error-handlingoptions that can be individually selected:<p><dl><dt><b>MEM_ALLOC_ERROR_LOG_FLAG</b><dd>Log a message when there is an error in allocating memory.<dt><b>MEM_ALLOC_ERROR_SUSPEND_FLAG</b><dd>Suspend the task when there is an error in allocating memory (unlessthe task was spawned with the <b>VX_UNBREAKABLE</b> option, in which case itcannot be suspended).<dt><b>MEM_BLOCK_ERROR_LOG_FLAG</b><dd>Log a message when there is an error in freeing memory.<dt><b>MEM_BLOCK_ERROR_SUSPEND_FLAG</b><dd>Suspend the task when there is an error in freeing memory (unlessthe task was spawned with the <b>VX_UNBREAKABLE</b> option, in which case itcannot be suspended).</dl>When the following option is specified to check every block freed to thepartition, <b><a href="./memPartLib.html#memPartFree">memPartFree</a>( )</b> and <b><a href="./memPartLib.html#free">free</a>( )</b> in <b><a href="./memPartLib.html#top">memPartLib</a></b> run consistency checksof various pointers and values in the header of the block being freed. Ifthis flag is not specified, no check will be performed when memory isfreed.<p><dl><dt><b>MEM_BLOCK_CHECK</b><dd>Check each block freed.</dl><p>Setting either of the <b>MEM_BLOCK_ERROR</b> options automatically sets <b>MEM_BLOCK_CHECK</b>.<p>The default options when a partition is created are:<p> <b>MEM_ALLOC_ERROR_LOG_FLAG</b><br> <b>MEM_BLOCK_CHECK</b><br> <b>MEM_BLOCK_ERROR_LOG_FLAG</b><br> <b>MEM_BLOCK_ERROR_SUSPEND_FLAG</b><p>When setting options for a partition with <b><a href="./memLib.html#memPartOptionsSet">memPartOptionsSet</a>( )</b> or<b><a href="./memLib.html#memOptionsSet">memOptionsSet</a>( )</b>, use the logical OR operator between each specifiedoption to construct the <i>options</i> parameter. For example:<pre> memPartOptionsSet (myPartId, MEM_ALLOC_ERROR_LOG_FLAG | MEM_BLOCK_CHECK | MEM_BLOCK_ERROR_LOG_FLAG);</pre></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>memLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memPartLib.html#top">memPartLib</a></b>, <b><a href="./smMemLib.html#top">smMemLib</a></b><p><hr><a name="memPartOptionsSet"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>memPartOptionsSet( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>memPartOptionsSet( )</strong> - set the debug options for a memory partition</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS memPartOptionsSet ( PART_ID partId, /* partition to set option for */ unsigned options /* memory management options */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine sets the debug options for a specified memory partition.Two kinds of errors are detected: attempts to allocate more memorythan is available, and bad blocks found when memory is freed. In bothcases, the error status is returned. There are four error-handlingoptions that can be individually selected:<p><dl><dt><b>MEM_ALLOC_ERROR_LOG_FLAG</b><dd>Log a message when there is an error in allocating memory.<dt><b>MEM_ALLOC_ERROR_SUSPEND_FLAG</b><dd>Suspend the task when there is an error in allocating memory (unlessthe task was spawned with the <b>VX_UNBREAKABLE</b> option, in which case itcannot be suspended).<dt><b>MEM_BLOCK_ERROR_LOG_FLAG</b><dd>Log a message when there is an error in freeing memory.<dt><b>MEM_BLOCK_ERROR_SUSPEND_FLAG</b><dd>Suspend the task when there is an error in freeing memory (unlessthe task was spawned with the <b>VX_UNBREAKABLE</b> option, in which case itcannot be suspended).</dl><p>These options are discussed in detail in the library manual entry for<b><a href="./memLib.html#top">memLib</a></b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR.<p></blockquote><h4>ERRNO</h4><blockquote><p><b>S_smObjLib_NOT_INITIALIZED</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memLib.html#top">memLib</a></b>, <b><a href="./smMemLib.html#top">smMemLib</a></b><hr><a name="memalign"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>memalign( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>memalign( )</strong> - allocate aligned memory </p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void *memalign ( unsigned alignment, /* boundary to align to (power of 2) */ unsigned size /* number of bytes to allocate */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine allocates a buffer of size <i>size</i> from the system memory partition. Additionally, it insures that the allocated buffer begins on a memory address evenly divisible by the specified alignment parameter.The alignment parameter must be a power of 2.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>A pointer to the newly allocated block, or NULL if the buffer could not beallocated.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./memLib.html#top">memLib</a></b><hr><a name="valloc"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>valloc( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>valloc( )</strong> - allocate memory on a page boundary </p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void * valloc ( unsigned size /* number of bytes to allocate */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -