<ahref="chmempools_8c.html">Go to the documentation of this file.</a><divclass="fragment"><preclass="fragment"><aname="l00001"></a>00001 <spanclass="comment">/*</span>
<aname="l00042"></a>00042 <spanclass="preprocessor">#include "<aclass="code"href="ch_8h.html"title="ChibiOS/RT main include file.">ch.h</a>"</span>
<aname="l00058"></a><aclass="code"href="group__pools.html#ga9c53c25a5ae60930534cde8620775781">00058</a><spanclass="keywordtype">void</span><aclass="code"href="group__pools.html#ga9c53c25a5ae60930534cde8620775781"title="Initializes an empty memory pool.">chPoolInit</a>(<aclass="code"href="struct_memory_pool.html"title="Memory pool descriptor.">MemoryPool</a> *mp, <spanclass="keywordtype">size_t</span> size, <aclass="code"href="group__memcore.html#ga4fb77ad6b1053341257948231799b4ad"title="Memory get function.">memgetfunc_t</a> provider) {
<aname="l00062"></a>00062 mp-><aclass="code"href="struct_memory_pool.html#ac1cf32748cc712049b503c2b00f99167"title="Pointer to the header.">mp_next</a> = NULL;
<aname="l00063"></a>00063 mp-><aclass="code"href="struct_memory_pool.html#a962ca1e05036d54213b3a0eeaebb0ec6"title="Memory pool objects size.">mp_object_size</a> = <aclass="code"href="group__memcore.html#ga216a7738be23e0caa9d18e510eb795eb"title="Alignment helper macro.">MEM_ALIGN_SIZE</a>(size);
<aname="l00064"></a>00064 mp-><aclass="code"href="struct_memory_pool.html#aa4b7af734cdd6976445d3502d6914428"title="Memory blocks provider for this pool.">mp_provider</a> = provider;
<aname="l00074"></a><aclass="code"href="group__pools.html#ga152fb3460d6b7426f0b6803bb38a0070">00074</a><spanclass="keywordtype">void</span> *<aclass="code"href="group__pools.html#ga152fb3460d6b7426f0b6803bb38a0070"title="Allocates an object from a memory pool.">chPoolAllocI</a>(<aclass="code"href="struct_memory_pool.html"title="Memory pool descriptor.">MemoryPool</a> *mp) {
<aname="l00079"></a>00079 <spanclass="keywordflow">if</span> ((objp = mp-><aclass="code"href="struct_memory_pool.html#ac1cf32748cc712049b503c2b00f99167"title="Pointer to the header.">mp_next</a>) != NULL)
<aname="l00080"></a>00080 mp-><aclass="code"href="struct_memory_pool.html#ac1cf32748cc712049b503c2b00f99167"title="Pointer to the header.">mp_next</a> = mp-><aclass="code"href="struct_memory_pool.html#ac1cf32748cc712049b503c2b00f99167"title="Pointer to the header.">mp_next</a>-><aclass="code"href="structpool__header.html#aac699414c648388563597a56e34adeb4"title="Pointer to the next pool header in the list.">ph_next</a>;
<aname="l00082"></a>00082 <spanclass="preprocessor"></span><spanclass="keywordflow">else</span><spanclass="keywordflow">if</span> (mp-><aclass="code"href="struct_memory_pool.html#aa4b7af734cdd6976445d3502d6914428"title="Memory blocks provider for this pool.">mp_provider</a> != NULL)
<aname="l00083"></a>00083 objp = mp-><aclass="code"href="struct_memory_pool.html#aa4b7af734cdd6976445d3502d6914428"title="Memory blocks provider for this pool.">mp_provider</a>(mp-><aclass="code"href="struct_memory_pool.html#a962ca1e05036d54213b3a0eeaebb0ec6"title="Memory pool objects size.">mp_object_size</a>);
<aname="l00095"></a><aclass="code"href="group__pools.html#gab86190d70893fe708c75570af6720bd5">00095</a><spanclass="keywordtype">void</span> *<aclass="code"href="group__pools.html#gab86190d70893fe708c75570af6720bd5"title="Allocates an object from a memory pool.">chPoolAlloc</a>(<aclass="code"href="struct_memory_pool.html"title="Memory pool descriptor.">MemoryPool</a> *mp) {
<aname="l00098"></a>00098 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00099"></a>00099 objp = <aclass="code"href="group__pools.html#ga152fb3460d6b7426f0b6803bb38a0070"title="Allocates an object from a memory pool.">chPoolAllocI</a>(mp);
<aname="l00100"></a>00100 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00114"></a><aclass="code"href="group__pools.html#gab5c6c04fd14fbeee2183ca955371c515">00114</a><spanclass="keywordtype">void</span><aclass="code"href="group__pools.html#gab5c6c04fd14fbeee2183ca955371c515"title="Releases (or adds) an object into (to) a memory pool.">chPoolFreeI</a>(<aclass="code"href="struct_memory_pool.html"title="Memory pool descriptor.">MemoryPool</a> *mp, <spanclass="keywordtype">void</span> *objp) {
<aname="l00115"></a>00115 <spanclass="keyword">struct </span><aclass="code"href="structpool__header.html"title="Memory pool free object header.">pool_header</a> *php = objp;
<aname="l00116"></a>00116
<aname="l00117"></a>00117 <aclass="code"href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844"title="Function parameter check.">chDbgCheck</a>((mp != NULL) && (objp != NULL) &&<aclass="code"href="group__memcore.html#gac38a64d9001b24d62f1c9ab79fbc328b"title="Returns whatever a pointer or memory size is aligned to the type align_t.">MEM_IS_ALIGNED</a>(objp),
<aname="l00120"></a>00120 php-><aclass="code"href="structpool__header.html#aac699414c648388563597a56e34adeb4"title="Pointer to the next pool header in the list.">ph_next</a> = mp-><aclass="code"href="struct_memory_pool.html#ac1cf32748cc712049b503c2b00f99167"title="Pointer to the header.">mp_next</a>;
<aname="l00121"></a>00121 mp-><aclass="code"href="struct_memory_pool.html#ac1cf32748cc712049b503c2b00f99167"title="Pointer to the header.">mp_next</a> = php;
<aname="l00132"></a><aclass="code"href="group__pools.html#ga978f8d038e8e981bf9e5a104b81c6cb6">00132</a><spanclass="keywordtype">void</span><aclass="code"href="group__pools.html#ga978f8d038e8e981bf9e5a104b81c6cb6"title="Releases (or adds) an object into (to) a memory pool.">chPoolFree</a>(<aclass="code"href="struct_memory_pool.html"title="Memory pool descriptor.">MemoryPool</a> *mp, <spanclass="keywordtype">void</span> *objp) {
<aname="l00133"></a>00133
<aname="l00134"></a>00134 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00135"></a>00135 <aclass="code"href="group__pools.html#gab5c6c04fd14fbeee2183ca955371c515"title="Releases (or adds) an object into (to) a memory pool.">chPoolFreeI</a>(mp, objp);
<aname="l00136"></a>00136 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
Generated on Sun Nov 28 2010 14:09:48 for ChibiOS/RT by <ahref="http://www.doxygen.org/index.html"><imgsrc="doxygen.png"alt="doxygen"align="middle"border="0"></a> 1.7.1</small></address>