malloc.html 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <html>
  2. <head>
  3. <title>malloc</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>malloc</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. malloc - allocate memory
  9. <h3>Library</h3>
  10. Standard C Library (libc, -lc)
  11. <h3>Synopsis</h3>
  12. #include &lt;stdlib.h&gt;<br>
  13. <br>
  14. void *<br>
  15. malloc(size_t <em>size</em>);
  16. <h3>Description</h3>
  17. malloc allocates <em>size</em> bytes of memory and returns a pointer
  18. to it. The memory is not necessarily zero-filled. (To get zero-filled
  19. memory, call <A HREF=bzero.html>bzero</A> or
  20. <A HREF=memset.html>memset</A>, or use
  21. <A HREF=calloc.html>calloc</A>.)
  22. <p>
  23. The pointer returned must be suitably aligned for use with any data
  24. type.
  25. <p>
  26. When asked to allocate zero bytes, malloc may either always return
  27. NULL, or may return distinct non-null pointers that do not point to
  28. any storage.
  29. <p>
  30. While malloc may at its option allocate more than <em>size</em> bytes
  31. to fill a request, code that calls malloc may not depend on such
  32. behavior and must not perform any accesses outside of the bounds
  33. defined by <em>size</em>.
  34. <p>
  35. It is legitimate for memory returned by malloc to not actually be
  36. physically mapped until it is used.
  37. <h3>Return Values</h3>
  38. malloc returns a pointer to the memory allocated. If memory cannot be
  39. obtained, NULL is returned.
  40. <h3>See Also</h3>
  41. <A HREF=calloc.html>calloc</A>,
  42. <A HREF=realloc.html>realloc</A>,
  43. <A HREF=free.html>free</A>
  44. </body>
  45. </html>