466
|
1 <refentry id="malloc">
|
|
2 <refnamediv>
|
527
|
3 <refname>Malloc</refname>
|
|
4 <refname>Free</refname>
|
|
5 <refname>Calloc</refname>
|
|
6 <refpurpose>memory allocation</refpurpose>
|
466
|
7 </refnamediv>
|
|
8
|
|
9 <refsynopsisdiv>
|
|
10 <funcsynopsis>
|
|
11 <funcprototype>
|
527
|
12 <funcdef>char *<function>malloc</function></funcdef>
|
|
13 <paramdef>unsigned <parameter>size</parameter></paramdef>
|
|
14 </funcprototype>
|
|
15
|
|
16 <funcprototype>
|
|
17 <funcdef><function>free</function></funcdef>
|
|
18 <paramdef>char *<parameter>ptr</parameter></paramdef>
|
|
19 </funcprototype>
|
|
20
|
|
21 <funcprototype>
|
|
22 <funcdef>char *<function>calloc</function></funcdef>
|
|
23 <paramdef>unsigned<parameter>nel</parameter></paramdef>
|
|
24 <paramdef>unsigned<parameter>elsize</parameter></paramdef>
|
466
|
25 </funcprototype>
|
|
26 </funcsynopsis>
|
|
27
|
|
28 </refsynopsisdiv>
|
|
29
|
|
30 <refsect1><title>Description</title>
|
|
31 <para>
|
527
|
32 Malloc returns a pointer to a block of at least "size" free bytes.
|
|
33 </para>
|
|
34 <para>
|
|
35 Free requires a pointer to a block that has been allocated by
|
|
36 malloc; it frees the space to be allocated again.
|
|
37 </para>
|
|
38 <para>
|
|
39 Calloc allocates space for an array. Nel is the number of
|
|
40 elements in the arrary, and elsize is the size of each element.
|
|
41 Calloc initializes the space to zero.
|
|
42 </para>
|
533
|
43 </refsect1>
|
527
|
44 <refsect1><title>Diagnostics</title>
|
|
45 <para>
|
|
46 Malloc, free, and calloc return NULL(0) if no free memory can
|
|
47 be found or if there was an error.
|
466
|
48 </para>
|
|
49 </refsect1>
|
|
50 </refentry>
|