free.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <html>
  2. <head>
  3. <title>free</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>free</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. free - release/deallocate 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(void *<em>ptr</em>);
  16. <h3>Description</h3>
  17. free releases a block of memory previously allocated with
  18. <A HREF=malloc.html>malloc</A>, <A HREF=calloc.html>calloc</A>,
  19. or <A HREF=realloc.html>realloc</A>.
  20. <p>
  21. Once free has been called, <em>ptr</em> is no longer valid and
  22. attempts to dereference it result in undefined behavior.
  23. (Pedantically, in fact, even using the <strong>value</strong> of
  24. <em>ptr</em> may produce undefined behavior.) Passing <em>ptr</em> to
  25. free a second or subsequent time (unless of course the same pointer
  26. value is again returned from malloc) is particularly likely to provoke
  27. undefined behavior in most implementations.
  28. <p>
  29. free(NULL) has no effect.
  30. <p>
  31. In practice it is desirable for implementations of free to detect, to
  32. the extent practically possible, pointers that were not previously
  33. allocated by one of the above functions or that are passed to free
  34. multiple times. However, this can be difficult and there is no useful
  35. standard mechanism for error reporting.
  36. <p>
  37. free does not necessarily unmap free memory or return it to the
  38. operating system, but may do so if it chooses.
  39. <h3>Return Values</h3>
  40. free returns no value.
  41. <h3>See Also</h3>
  42. <A HREF=calloc.html>calloc</A>,
  43. <A HREF=malloc.html>malloc</A>,
  44. <A HREF=realloc.html>realloc</A>
  45. </body>
  46. </html>