root/man/libc/malloc.html

/* [<][>][^][v][top][bottom][index][help] */
<html>
<head>
<title>malloc</title>
<body bgcolor=#ffffff>
<h2 align=center>malloc</h2>
<h4 align=center>OS/161 Reference Manual</h4>

<h3>Name</h3>
malloc - allocate memory

<h3>Library</h3>
Standard C Library (libc, -lc)

<h3>Synopsis</h3>
#include &lt;stdlib.h&gt;<br>
<br>
void *<br>
malloc(size_t <em>size</em>);

<h3>Description</h3>

malloc allocates <em>size</em> bytes of memory and returns a pointer
to it. The memory is not necessarily zero-filled. (To get zero-filled
memory, call <A HREF=bzero.html>bzero</A> or 
<A HREF=memset.html>memset</A>, or use
<A HREF=calloc.html>calloc</A>.) 
<p>

The pointer returned must be suitably aligned for use with any data
type.
<p>

When asked to allocate zero bytes, malloc may either always return
NULL, or may return distinct non-null pointers that do not point to
any storage.
<p>

While malloc may at its option allocate more than <em>size</em> bytes
to fill a request, code that calls malloc may not depend on such
behavior and must not perform any accesses outside of the bounds
defined by <em>size</em>.
<p>

It is legitimate for memory returned by malloc to not actually be
physically mapped until it is used.

<h3>Return Values</h3>
malloc returns a pointer to the memory allocated. If memory cannot be
obtained, NULL is returned.

<h3>See Also</h3>
<A HREF=calloc.html>calloc</A>,
<A HREF=realloc.html>realloc</A>,
<A HREF=free.html>free</A>

</body>
</html>

/* [<][>][^][v][top][bottom][index][help] */