| <html lang="en"> |
| <head> |
| <title>calloc - Untitled</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Untitled"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Stdlib.html#Stdlib" title="Stdlib"> |
| <link rel="prev" href="bsearch.html#bsearch" title="bsearch"> |
| <link rel="next" href="div.html#div" title="div"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="calloc"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="div.html#div">div</a>, |
| Previous: <a rel="previous" accesskey="p" href="bsearch.html#bsearch">bsearch</a>, |
| Up: <a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">2.11 <code>calloc</code>—allocate space for arrays</h3> |
| |
| <p><a name="index-calloc-17"></a><a name="index-g_t_005fcalloc_005fr-18"></a><strong>Synopsis</strong> |
| <pre class="example"> #include <stdlib.h> |
| void *calloc(size_t <var>n</var>, size_t <var>s</var>); |
| void *_calloc_r(void *<var>reent</var>, size_t <var>n</var>, size_t <var>s</var>); |
| </pre> |
| <p><strong>Description</strong><br> |
| Use <code>calloc</code> to request a block of memory sufficient to hold an |
| array of <var>n</var> elements, each of which has size <var>s</var>. |
| |
| <p>The memory allocated by <code>calloc</code> comes out of the same memory pool |
| used by <code>malloc</code>, but the memory block is initialized to all zero |
| bytes. (To avoid the overhead of initializing the space, use |
| <code>malloc</code> instead.) |
| |
| <p>The alternate function <code>_calloc_r</code> is reentrant. |
| The extra argument <var>reent</var> is a pointer to a reentrancy structure. |
| |
| <p><br> |
| <strong>Returns</strong><br> |
| If successful, a pointer to the newly allocated space. |
| |
| <p>If unsuccessful, <code>NULL</code>. |
| |
| <p><br> |
| <strong>Portability</strong><br> |
| <code>calloc</code> is ANSI. |
| |
| <p>Supporting OS subroutines required: <code>close</code>, <code>fstat</code>, <code>isatty</code>, |
| <code>lseek</code>, <code>read</code>, <code>sbrk</code>, <code>write</code>. |
| |
| <p><br> |
| |
| </body></html> |
| |