⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 brk.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>brk</title></head><body bgcolor=white><center><font size=2>The Single UNIX &reg; Specification, Version 2<br>Copyright &copy; 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_001_296">&nbsp;</a>NAME</h4><blockquote>brk, sbrk - change space allocation(<b>LEGACY</b>)</blockquote><h4><a name = "tag_000_001_297">&nbsp;</a>SYNOPSIS</h4><blockquote><pre><code>#include &lt;<a href="unistd.h.html">unistd.h</a>&gt;int brk(void *<i>addr</i>);void *sbrk(intptr_t <i>incr</i>);</code></pre></blockquote><h4><a name = "tag_000_001_298">&nbsp;</a>DESCRIPTION</h4><blockquote>The<i>brk()</i>and<i><a href="sbrk.html">sbrk()</a></i>functions are used to change the amount of space allocated for the callingprocess.  The change is made by resetting the process' break value andallocating the appropriate amount of space.  The amount of allocated spaceincreases as the break value increases.  The newly-allocated space is set to0.  However, if the application first decrements and then increments the breakvalue, the contents of the reallocated space are unspecified.<p>The<i>brk()</i>function sets the break value to<i>addr</i>and changes the allocated space accordingly.<p>The<i><a href="sbrk.html">sbrk()</a></i>function adds<i>incr</i>bytes to the break value and changes the allocated space accordingly.  If<i>incr</i>is negative, the amount of allocated space is decreased by<i>incr</i>bytes.  The current value of the program break is returned by <i>sbrk</i>(0).<p>The behaviour of<i>brk()</i>and<i><a href="sbrk.html">sbrk()</a></i>is unspecified if an application also uses any other memory functions (such as<i><a href="malloc.html">malloc()</a></i>,<i><a href="mmap.html">mmap()</a></i>,<i><a href="free.html">free()</a></i>).Other functions may use these other memory functions silently.<p>It is unspecified whether the pointer returned by<i><a href="sbrk.html">sbrk()</a></i>is aligned suitably for any purpose.<p>These interfaces need not be reentrant.</blockquote><h4><a name = "tag_000_001_299">&nbsp;</a>RETURN VALUE</h4><blockquote>Upon successful completion,<i>brk()</i>returns 0.  Otherwise, it returns -1 and sets<i>errno</i>to indicate the error.<p>Upon successful completion,<i><a href="sbrk.html">sbrk()</a></i>returns the prior break value.  Otherwise, it returns (<b>void&nbsp;*</b>)-1 andsets<i>errno</i>to indicate the error.</blockquote><h4><a name = "tag_000_001_300">&nbsp;</a>ERRORS</h4><blockquote>The<i>brk()</i>and<i><a href="sbrk.html">sbrk()</a></i>functions will fail if:<dl compact><dt>[ENOMEM]<dd>The requested change would allocate more space than allowed.</dl><p>The<i>brk()</i>and<i><a href="sbrk.html">sbrk()</a></i>functions may fail if:<dl compact><dt>[EAGAIN]<dd>The total amount of system memory available for allocation to thisprocess is temporarily insufficient.  This may occur even thoughthe space requested was less than the maximum data segment size.<dt>[ENOMEM]<dd>The requested change would be impossible as there is insufficient swap spaceavailable, or would cause a memory allocation conflict.</dl></blockquote><h4><a name = "tag_000_001_301">&nbsp;</a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_302">&nbsp;</a>APPLICATION USAGE</h4><blockquote>The<i>brk()</i>and<i><a href="sbrk.html">sbrk()</a></i>functions have been used in specialised cases where no other memory allocationfunction provided the same capability.  The use of<i><a href="malloc.html">malloc()</a></i>is now preferred because it can be used portably with all other memoryallocation functions and with any function that uses other allocationfunctions.</blockquote><h4><a name = "tag_000_001_303">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_304">&nbsp;</a>SEE ALSO</h4><blockquote><i><a href="exec.html">exec</a></i>,<i><a href="malloc.html">malloc()</a></i>,<i><a href="mmap.html">mmap()</a></i>,<i><a href="unistd.h.html">&lt;unistd.h&gt;</a></i>.<br></blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -