| <head> |
| <title>bin(3) - Plan 9 from User Space</title> |
| <meta content="text/html; charset=utf-8" http-equiv=Content-Type> |
| </head> |
| <body bgcolor=#ffffff> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=10><td> |
| <tr><td width=20><td> |
| <tr><td width=20><td><b>BIN(3)</b><td align=right><b>BIN(3)</b> |
| <tr><td width=20><td colspan=2> |
| <br> |
| <p><font size=+1><b>NAME </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| binalloc, bingrow, binfree – grouped memory allocation<br> |
| |
| </table> |
| <p><font size=+1><b>SYNOPSIS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>#include <u.h><br> |
| #include <libc.h><br> |
| #include <bin.h> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct BinBin; |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>void *binalloc(Bin **bp, ulong size, int clr); |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>void *bingrow(Bin **bp, void *op, ulong osize,<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| ulong size, int clr); |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| </table> |
| |
| </table> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| |
| </table> |
| |
| </table> |
| <tt><font size=+1>void binfree(Bin **bp);<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>DESCRIPTION </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| These routines provide simple grouped memory allocation and deallocation. |
| Items allocated with <i>binalloc</i> are added to the <i>Bin</i> pointed to |
| by <i>bp</i>. All items in a bin may be freed with one call to <i>binfree</i>; |
| there is no way to free a single item. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Binalloc</i> returns a pointer to a new block of at least <i>size</i> bytes. |
| The block is suitably aligned for storage of any type of object. |
| No two active pointers from <i>binalloc</i> will have the same value. |
| The call <tt><font size=+1>binalloc(0)</font></tt> returns a valid pointer rather than null. |
| If <i>clr</i> is non-zero, the allocated memory is set to 0; otherwise, |
| the contents are undefined. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Bingrow</i> is used to extend the size of a block of memory returned |
| by <i>binalloc</i>. <i>Bp</i> must point to the same bin group used to allocate |
| the original block, and <i>osize</i> must be the last size used to allocate |
| or grow the block. A pointer to a block of at least <i>size</i> bytes |
| is returned, with the same contents in the first <i>osize |
| </i>locations. If <i>clr</i> is non-zero, the remaining bytes are set to |
| 0, and are undefined otherwise. If <i>op</i> is <tt><font size=+1>nil</font></tt>, it and <i>osize</i> are |
| ignored, and the result is the same as calling <i>binalloc</i>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Binalloc</i> and <i>bingrow</i> allocate large chunks of memory using <a href="../man3/malloc.html"><i>malloc</i>(3)</a> |
| and return pieces of these chunks. The chunks are <i>free</i>’d upon |
| a call to <i>binfree</i>.<br> |
| |
| </table> |
| <p><font size=+1><b>SOURCE </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>/usr/local/plan9/src/libbin<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>SEE ALSO </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <a href="../man3/malloc.html"><i>malloc</i>(3)</a><br> |
| |
| </table> |
| <p><font size=+1><b>DIAGNOSTICS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>binalloc</i> and <i>bingrow</i> return 0 if there is no available memory.<br> |
| |
| </table> |
| |
| <td width=20> |
| <tr height=20><td> |
| </table> |
| <!-- TRAILER --> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=15><td width=10><td><td width=10> |
| <tr><td><td> |
| <center> |
| <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> |
| </center> |
| </table> |
| <!-- TRAILER --> |
| </body></html> |