forked from Imagelibrary/uip
66 lines
5.0 KiB
HTML
66 lines
5.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|
<title>uIP 0.9: memb.c File Reference</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
</head><body>
|
|
<!-- Generated by Doxygen 1.3.3 -->
|
|
<div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
|
|
<h1>apps/telnetd/memb.c File Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
|
|
Memory block allocation routines.
|
|
<p>
|
|
<dl compact><dt><b>Author:</b></dt><dd>Adam Dunkels <<a href="mailto:adam@sics.se">adam@sics.se</a>></dd></dl>
|
|
The memory block allocation routines provide a simple yet powerful set of functions for managing a set of memory blocks of fixed size. A set of memory blocks is statically declared with the <a class="el" href="a00076.html#a4">MEMB()</a> macro. Memory blocks are allocated from the declared memory by the <a class="el" href="a00076.html#a1">memb_alloc()</a> function, and are deallocated with the <a class="el" href="a00076.html#a3">memb_free()</a> function.<p>
|
|
<dl compact><dt><b>Note:</b></dt><dd>Because of namespace clashes only one <a class="el" href="a00076.html#a4">MEMB()</a> can be declared per C module, and the name scope of a <a class="el" href="a00076.html#a4">MEMB()</a> memory block is local to each C module.</dd></dl>
|
|
The following example shows how to declare and use a memory block called "cmem" which has 8 chunks of memory with each memory chunk being 20 bytes large.<p>
|
|
<div class="fragment"><pre> <a class="code" href="a00076.html#a4">MEMB</a>(cmem, 20, 8);
|
|
|
|
<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) {
|
|
<span class="keywordtype">char</span> *ptr;
|
|
|
|
<a class="code" href="a00076.html#a0">memb_init</a>(&cmem);
|
|
|
|
ptr = <a class="code" href="a00076.html#a1">memb_alloc</a>(&cmem);
|
|
|
|
<span class="keywordflow">if</span>(ptr != NULL) {
|
|
do_something(ptr);
|
|
} <span class="keywordflow">else</span> {
|
|
printf(<span class="stringliteral">"Could not allocate memory.\n"</span>);
|
|
}
|
|
|
|
<span class="keywordflow">if</span>(<a class="code" href="a00076.html#a2">memb_free</a>(ptr) == 0) {
|
|
printf(<span class="stringliteral">"Deallocation succeeded.\n"</span>);
|
|
}
|
|
}
|
|
</pre></div>
|
|
<p>
|
|
<code>#include <string.h></code><br>
|
|
<code>#include "<a class="el" href="a00060.html">memb.h</a>"</code><br>
|
|
|
|
<p>
|
|
Include dependency graph for memb.c:<p><center><img src="a00116.png" border="0" usemap="#memb.c_map" alt="Include dependency graph"></center>
|
|
<map name="memb.c_map">
|
|
<area href="a00060.html" shape="rect" coords="84,16,143,37" alt="">
|
|
</map>
|
|
<table border=0 cellpadding=0 cellspacing=0>
|
|
<tr><td></td></tr>
|
|
<tr><td colspan=2><br><h2>Functions</h2></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a00076.html#a0">memb_init</a> (struct memb_blocks *m)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Initialize a memory block that was declared with <a class="el" href="a00076.html#a4">MEMB()</a>. </em> <a href="a00076.html#a0"></a><em><br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>char * </td><td class="memItemRight" valign=bottom><a class="el" href="a00076.html#a1">memb_alloc</a> (struct memb_blocks *m)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Allocate a memory block from a block of memory declared with <a class="el" href="a00076.html#a4">MEMB()</a>. </em> <a href="a00076.html#a1"></a><em><br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>char </td><td class="memItemRight" valign=bottom><a class="el" href="a00076.html#a2">memb_free</a> (struct memb_blocks *m, char *ptr)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Deallocate a memory block from a memory block previously declared with <a class="el" href="a00076.html#a4">MEMB()</a>. </em> <a href="a00076.html#a2"></a><em><br><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>char </td><td class="memItemRight" valign=bottom><a class="el" href="a00076.html#a3">memb_ref</a> (struct memb_blocks *m, char *ptr)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Increase the reference count for a memory chunk. </em> <a href="a00076.html#a3"></a><em><br><br></td></tr>
|
|
</table>
|
|
<hr size="1"><address style="align: right;"><small>Generated on Tue Oct 7 15:51:14 2003 for uIP 0.9 by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
|
|
</a>1.3.3 </small></address>
|
|
</body>
|
|
</html>
|