realloc.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <html>
  2. <head>
  3. <title>realloc</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>realloc</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. realloc - resize allocated 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. realloc(void *<em>ptr</em>, size_t <em>newsize</em>);
  16. <h3>Description</h3>
  17. realloc attempts to change the size of the memory block pointed to by
  18. <em>ptr</em> to <em>newsize</em>, causing the block to shrink or grow
  19. as necessary. The size of NULL is treated as 0. Any newly allocated
  20. space has undefined contents; the contents of existing space not
  21. discarded by shrinkage are preserved.
  22. <p>
  23. <em>ptr</em> be NULL or have been previously returned by
  24. <A HREF=malloc.html>malloc</A>, <A HREF=calloc.html>calloc</A>, or
  25. realloc.
  26. <p>
  27. The alignment and other restrictions described for
  28. <A HREF=malloc.html>malloc</A> apply equally to realloc.
  29. <p>
  30. <h3>Return Values</h3>
  31. realloc returns a pointer to the resized memory block. This may not be
  32. the same pointer as <em>ptr</em> if for internal reasons it is
  33. necessary to move the memory block. If such a move takes place, the
  34. old block is invalidated and <em>ptr</em> becomes invalid.
  35. <p>
  36. If the resize operation cannot be performed, NULL is returned, in
  37. which case the original block pointed to by <em>ptr</em> is untouched
  38. and remains valid.
  39. <p>
  40. <h3>See Also</h3>
  41. <A HREF=calloc.html>calloc</A>,
  42. <A HREF=malloc.html>malloc</A>,
  43. <A HREF=free.html>free</A>
  44. </body>
  45. </html>