亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? library_3.html

?? linux_c函數,linux下編程必備的
?? HTML
?? 第 1 頁 / 共 5 頁
字號:
of the program's space is given back to the system when the process
terminates.
<P>
<A NAME="IDX146"></A>
<H3><A NAME="SEC25" HREF="library_toc.html#SEC25" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC25">Changing the Size of a Block</A></H3>
<P>
Often you do not know for certain how big a block you will ultimately need
at the time you must begin to use the block.  For example, the block might
be a buffer that you use to hold a line being read from a file; no matter
how long you make the buffer initially, you may encounter a line that is
longer.
<P>
You can make the block longer by calling <CODE>realloc</CODE>.  This function
is declared in <TT>`stdlib.h'</TT>.
<A NAME="IDX147"></A>
<P>
<A NAME="IDX148"></A>
<U>Function:</U> void * <B>realloc</B> <I>(void *<VAR>ptr</VAR>, size_t <VAR>newsize</VAR>)</I><P>
The <CODE>realloc</CODE> function changes the size of the block whose address is
<VAR>ptr</VAR> to be <VAR>newsize</VAR>.
<P>
Since the space after the end of the block may be in use, <CODE>realloc</CODE>
may find it necessary to copy the block to a new address where more free
space is available.  The value of <CODE>realloc</CODE> is the new address of the
block.  If the block needs to be moved, <CODE>realloc</CODE> copies the old
contents.
<P>
Like <CODE>malloc</CODE>, <CODE>realloc</CODE> may return a null pointer if no
memory space is available to make the block bigger.  When this happens,
the original block is untouched; it has not been modified or relocated.
<P>
In most cases it makes no difference what happens to the original block
when <CODE>realloc</CODE> fails, because the application program cannot continue
when it is out of memory, and the only thing to do is to give a fatal error
message.  Often it is convenient to write and use a subroutine,
conventionally called <CODE>xrealloc</CODE>, that takes care of the error message
as <CODE>xmalloc</CODE> does for <CODE>malloc</CODE>:
<P>
<PRE>
void *
xrealloc (void *ptr, size_t size)
{
  register void *value = realloc (ptr, size);
  if (value == 0)
    fatal ("Virtual memory exhausted");
  return value;
}
</PRE>
<P>
You can also use <CODE>realloc</CODE> to make a block smaller.  The reason you
would do this is to avoid tying up a lot of memory space when only a little
is needed.  Making a block smaller sometimes necessitates copying it, so it
can fail if no other space is available.
<P>
If the new size you specify is the same as the old size, <CODE>realloc</CODE>
is guaranteed to change nothing and return the same address that you gave.
<P>
<H3><A NAME="SEC26" HREF="library_toc.html#SEC26" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC26">Allocating Cleared Space</A></H3>
<P>
The function <CODE>calloc</CODE> allocates memory and clears it to zero.  It
is declared in <TT>`stdlib.h'</TT>.
<A NAME="IDX149"></A>
<P>
<A NAME="IDX150"></A>
<U>Function:</U> void * <B>calloc</B> <I>(size_t <VAR>count</VAR>, size_t <VAR>eltsize</VAR>)</I><P>
This function allocates a block long enough to contain a vector of
<VAR>count</VAR> elements, each of size <VAR>eltsize</VAR>.  Its contents are
cleared to zero before <CODE>calloc</CODE> returns.
<P>
You could define <CODE>calloc</CODE> as follows:
<P>
<PRE>
void *
calloc (size_t count, size_t eltsize)
{
  size_t size = count * eltsize;
  void *value = malloc (size);
  if (value != 0)
    memset (value, 0, size);
  return value;
}
</PRE>
<P>
We rarely use <CODE>calloc</CODE> today, because it is equivalent to such a
simple combination of other features that are more often used.  It is a
historical holdover that is not quite obsolete.
<P>
<A NAME="IDX151"></A>
<H3><A NAME="SEC27" HREF="library_toc.html#SEC27" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC27">Efficiency Considerations for <CODE>malloc</CODE></A></H3>
<P>
To make the best use of <CODE>malloc</CODE>, it helps to know that the GNU
version of <CODE>malloc</CODE> always dispenses small amounts of memory in
blocks whose sizes are powers of two.  It keeps separate pools for each
power of two.  This holds for sizes up to a page size.  Therefore, if
you are free to choose the size of a small block in order to make
<CODE>malloc</CODE> more efficient, make it a power of two.
<P>
Once a page is split up for a particular block size, it can't be reused
for another size unless all the blocks in it are freed.  In many
programs, this is unlikely to happen.  Thus, you can sometimes make a
program use memory more efficiently by using blocks of the same size for
many different purposes.
<P>
When you ask for memory blocks of a page or larger, <CODE>malloc</CODE> uses a
different strategy; it rounds the size up to a multiple of a page, and
it can coalesce and split blocks as needed.
<P>
The reason for the two strategies is that it is important to allocate
and free small blocks as fast as possible, but speed is less important
for a large block since the program normally spends a fair amount of
time using it.  Also, large blocks are normally fewer in number.
Therefore, for large blocks, it makes sense to use a method which takes
more time to minimize the wasted space.
<P>
<H3><A NAME="SEC28" HREF="library_toc.html#SEC28" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC28">Allocating Aligned Memory Blocks</A></H3>
<A NAME="IDX152"></A>
<A NAME="IDX153"></A>
<A NAME="IDX154"></A>
<P>
The address of a block returned by <CODE>malloc</CODE> or <CODE>realloc</CODE> in
the GNU system is always a multiple of eight.  If you need a block whose
address is a multiple of a higher power of two than that, use
<CODE>memalign</CODE> or <CODE>valloc</CODE>.  These functions are declared in
<TT>`stdlib.h'</TT>.
<P>
With the GNU library, you can use <CODE>free</CODE> to free the blocks that
<CODE>memalign</CODE> and <CODE>valloc</CODE> return.  That does not work in BSD,
however--BSD does not provide any way to free such blocks.
<P>
<A NAME="IDX155"></A>
<U>Function:</U> void * <B>memalign</B> <I>(size_t <VAR>size</VAR>, int <VAR>boundary</VAR>)</I><P>
The <CODE>memalign</CODE> function allocates a block of <VAR>size</VAR> bytes whose
address is a multiple of <VAR>boundary</VAR>.  The <VAR>boundary</VAR> must be a
power of two!  The function <CODE>memalign</CODE> works by calling
<CODE>malloc</CODE> to allocate a somewhat larger block, and then returning an
address within the block that is on the specified boundary.
<P>
<A NAME="IDX156"></A>
<U>Function:</U> void * <B>valloc</B> <I>(size_t <VAR>size</VAR>)</I><P>
Using <CODE>valloc</CODE> is like using <CODE>memalign</CODE> and passing the page size
as the value of the second argument.
<P>
<H3><A NAME="SEC29" HREF="library_toc.html#SEC29" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC29">Heap Consistency Checking</A></H3>
<A NAME="IDX157"></A>
<A NAME="IDX158"></A>
<P>
You can ask <CODE>malloc</CODE> to check the consistency of dynamic storage by
using the <CODE>mcheck</CODE> function.  This function is a GNU extension,
declared in <TT>`malloc.h'</TT>.
<A NAME="IDX159"></A>
<P>
<A NAME="IDX160"></A>
<U>Function:</U> void <B>mcheck</B> <I>(void (*<VAR>abortfn</VAR>) (void))</I><P>
Calling <CODE>mcheck</CODE> tells <CODE>malloc</CODE> to perform occasional
consistency checks.  These will catch things such as writing
past the end of a block that was allocated with <CODE>malloc</CODE>.
<P>
The <VAR>abortfn</VAR> argument is the function to call when an inconsistency
is found.  If you supply a null pointer, the <CODE>abort</CODE> function is
used.
<P>
It is too late to begin allocation checking once you have allocated
anything with <CODE>malloc</CODE>.  So <CODE>mcheck</CODE> does nothing in that
case.  The function returns <CODE>-1</CODE> if you call it too late, and
<CODE>0</CODE> otherwise (when it is successful).
<P>
The easiest way to arrange to call <CODE>mcheck</CODE> early enough is to use
the option <SAMP>`-lmcheck'</SAMP> when you link your program.
<P>
<A NAME="IDX161"></A>
<H3><A NAME="SEC30" HREF="library_toc.html#SEC30" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC30">Storage Allocation Hooks</A></H3>
<P>
The GNU C library lets you modify the behavior of <CODE>malloc</CODE>,
<CODE>realloc</CODE>, and <CODE>free</CODE> by specifying appropriate hook
functions.  You can use these hooks to help you debug programs that use
dynamic storage allocation, for example.
<P>
The hook variables are declared in <TT>`malloc.h'</TT>.
<A NAME="IDX162"></A>
<P>
<A NAME="IDX163"></A>
<U>Variable:</U> <B>__malloc_hook</B><P>
The value of this variable is a pointer to function that <CODE>malloc</CODE>
uses whenever it is called.  You should define this function to look
like <CODE>malloc</CODE>; that is, like:
<P>
<PRE>
void *<VAR>function</VAR> (size_t <VAR>size</VAR>)
</PRE>
<P>
<A NAME="IDX164"></A>
<U>Variable:</U> <B>__realloc_hook</B><P>
The value of this variable is a pointer to function that <CODE>realloc</CODE>
uses whenever it is called.  You should define this function to look
like <CODE>realloc</CODE>; that is, like:
<P>
<PRE>
void *<VAR>function</VAR> (void *<VAR>ptr</VAR>, size_t <VAR>size</VAR>)
</PRE>
<P>
<A NAME="IDX165"></A>
<U>Variable:</U> <B>__free_hook</B><P>
The value of this variable is a pointer to function that <CODE>free</CODE>
uses whenever it is called.  You should define this function to look
like <CODE>free</CODE>; that is, like:
<P>
<PRE>
void <VAR>function</VAR> (void *<VAR>ptr</VAR>)
</PRE>
<P>
You must make sure that the function you install as a hook for one of
these functions does not call that function recursively without restoring
the old value of the hook first!  Otherwise, your program will get stuck
in an infinite recursion.
<P>
Here is an example showing how to use <CODE>__malloc_hook</CODE> properly.  It
installs a function that prints out information every time <CODE>malloc</CODE>
is called.
<P>
<PRE>
static void *(*old_malloc_hook) (size_t);
static void *
my_malloc_hook (size_t size)
{
  void *result;
  __malloc_hook = old_malloc_hook;
  result = malloc (size);
  __malloc_hook = my_malloc_hook;
  printf ("malloc (%u) returns %p\n", (unsigned int) size, result);
  return result;
}

main ()
{
  ...
  old_malloc_hook = __malloc_hook;
  __malloc_hook = my_malloc_hook;
  ...
}
</PRE>
<P>
The <CODE>mcheck</CODE> function (see section <A HREF="library_3.html#SEC29" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_3.html#SEC29">Heap Consistency Checking</A>) works by
installing such hooks.
<P>
<H3><A NAME="SEC31" HREF="library_toc.html#SEC31" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC31">Statistics for Storage Allocation with <CODE>malloc</CODE></A></H3>
<A NAME="IDX166"></A>
<P>
You can get information about dynamic storage allocation by calling the
<CODE>mstats</CODE> function.  This function and its associated data type are
declared in <TT>`malloc.h'</TT>; they are a GNU extension.
<A NAME="IDX167"></A>
<P>
<A NAME="IDX168"></A>
<U>Data Type:</U> <B>struct mstats</B><P>
This structure type is used to return information about the dynamic
storage allocator.  It contains the following members:
<P>
<DL COMPACT>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区在线观看免费| 亚洲人成网站影音先锋播放| 99久久国产综合精品女不卡| 国产揄拍国内精品对白| 免费亚洲电影在线| 免费人成精品欧美精品 | 久久99国产精品免费网站| 亚洲一区二区视频| 午夜久久久久久久久| 亚洲大片免费看| 日本欧洲一区二区| 久久国内精品视频| 国产不卡一区视频| 成人av免费网站| 色呦呦一区二区三区| 欧洲激情一区二区| 欧美一区二区在线视频| 欧美一区二区福利在线| 久久婷婷国产综合国色天香| 久久精品欧美一区二区三区麻豆| 久久亚洲一级片| 中文字幕日韩欧美一区二区三区| 综合分类小说区另类春色亚洲小说欧美| 国产精品私人自拍| 一区二区三区视频在线看| 五月综合激情日本mⅴ| 美洲天堂一区二卡三卡四卡视频| 国产综合色产在线精品| 91色婷婷久久久久合中文| 欧美乱妇15p| 久久久国产精品麻豆| 亚洲女与黑人做爰| 美女诱惑一区二区| 91在线播放网址| 69av一区二区三区| 国产精品丝袜久久久久久app| 亚洲精品成a人| 韩国成人福利片在线播放| 99精品视频免费在线观看| 欧美喷潮久久久xxxxx| 欧美激情在线观看视频免费| 亚洲综合色视频| 国产aⅴ精品一区二区三区色成熟| 91污片在线观看| 欧美成人性福生活免费看| 亚洲女人的天堂| 韩国精品在线观看| 制服丝袜一区二区三区| 国产精品动漫网站| 激情文学综合丁香| 欧美日韩一级黄| 中文字幕亚洲成人| 国内不卡的二区三区中文字幕| 91首页免费视频| 久久久久免费观看| 日本中文字幕一区二区有限公司| 99久久亚洲一区二区三区青草| 欧美成人在线直播| 亚洲福利视频一区| 一本色道久久综合亚洲91| 久久亚洲综合色一区二区三区| 亚洲不卡av一区二区三区| 99re在线精品| 国产精品初高中害羞小美女文| 久久www免费人成看片高清| 91国产福利在线| 日韩一区欧美一区| 成人精品一区二区三区四区 | 国产不卡高清在线观看视频| 日韩午夜精品视频| 日韩主播视频在线| 欧美肥胖老妇做爰| 日韩精品免费视频人成| 欧美日韩国产乱码电影| 亚洲免费伊人电影| 91丨九色丨尤物| 日韩伦理电影网| www.欧美日韩国产在线| 中文幕一区二区三区久久蜜桃| 国产精品一区三区| 国产嫩草影院久久久久| 国产综合久久久久久久久久久久 | 精品一区二区日韩| 欧美成人高清电影在线| 韩国精品免费视频| 国产精品进线69影院| www.久久精品| 亚洲综合一二区| 制服丝袜激情欧洲亚洲| 久久99国产精品免费网站| 久久综合色天天久久综合图片| 国产电影一区二区三区| 国产精品精品国产色婷婷| 色婷婷综合视频在线观看| 亚洲.国产.中文慕字在线| 91.麻豆视频| 国产乱子伦视频一区二区三区| 日本一区二区三区高清不卡| 91丨porny丨最新| 性久久久久久久久久久久| 日韩视频一区二区三区在线播放| 精品一区二区三区影院在线午夜| 国产清纯美女被跳蛋高潮一区二区久久w | 国产亚洲综合色| av激情亚洲男人天堂| 亚洲综合一区在线| 久久亚洲捆绑美女| 日本精品一级二级| 美国三级日本三级久久99| 国产精品视频一二三| 欧美三级资源在线| 国产精品1024久久| 亚洲国产精品久久人人爱蜜臀| 日韩精品中文字幕一区二区三区 | 懂色av中文字幕一区二区三区| 综合欧美亚洲日本| 制服.丝袜.亚洲.中文.综合| 国产一区在线观看视频| 一区二区三区国产精品| 精品欧美久久久| 在线免费观看日本一区| 国产一区二区免费视频| 亚洲一区二区三区在线看| 久久久99精品久久| 337p亚洲精品色噜噜噜| 97se亚洲国产综合自在线| 毛片av中文字幕一区二区| 亚洲精品中文字幕乱码三区| 精品美女一区二区| 欧美精品色一区二区三区| 成人精品小蝌蚪| 国产在线视视频有精品| 日韩激情在线观看| 一区二区三区在线看| 国产精品你懂的在线欣赏| 久久综合久久综合久久综合| 欧美日韩一级二级三级| 色综合天天性综合| 国产超碰在线一区| 国产在线国偷精品免费看| 视频一区欧美日韩| 亚洲图片自拍偷拍| 国产精品情趣视频| 国产视频不卡一区| 久久九九国产精品| 日韩精品一区二区三区四区视频 | 久久国产成人午夜av影院| 亚洲成av人片一区二区三区| 亚洲女同一区二区| 亚洲少妇30p| 最新高清无码专区| 国产精品久久久久影视| 国产欧美va欧美不卡在线| 久久久激情视频| 国产午夜精品久久久久久久| 亚洲精品一区二区三区蜜桃下载| 日韩一区二区三区高清免费看看| 91精品免费在线观看| 欧美日韩一区不卡| 欧美亚洲免费在线一区| 欧美日韩一级黄| 538prom精品视频线放| 日韩丝袜情趣美女图片| 欧美成人video| 久久伊人中文字幕| 国产精品久线在线观看| 亚洲欧美日韩一区| 亚洲国产成人91porn| 亚洲国产美国国产综合一区二区| 亚洲成在线观看| 免费看精品久久片| 久久99精品久久久久久动态图| 精品一区二区三区视频在线观看 | 91片黄在线观看| 在线观看视频91| 91精品国产高清一区二区三区蜜臀| 欧美一区日本一区韩国一区| 欧美精品一区二| ●精品国产综合乱码久久久久| 亚洲激情自拍偷拍| 秋霞电影网一区二区| 国产精品亚洲午夜一区二区三区 | 一区二区三区在线观看国产| 亚洲成人三级小说| 国产激情视频一区二区三区欧美| eeuss鲁一区二区三区| 欧美日韩一区不卡| 国产视频一区二区在线观看| 亚洲综合色噜噜狠狠| 九九**精品视频免费播放| 成人av动漫在线| 欧美一区二区精品在线| 欧美韩日一区二区三区四区| 亚洲成人三级小说| 成人av小说网| 精品蜜桃在线看| 香蕉影视欧美成人| 99视频一区二区| xf在线a精品一区二区视频网站| 亚洲精品国久久99热|