Realloc.c 654 B

123456789101112131415161718192021222324252627282930313233
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* M E M O R Y A L L O C A T I O N R O U T I N E S */
  7. /* The memory allocation routines offered in this file are:
  8. char *Realloc(ptr, n) : reallocate buffer to n bytes
  9. */
  10. #if __STDC__
  11. #include <stdlib.h>
  12. #else
  13. extern char *malloc();
  14. extern char *realloc();
  15. #endif
  16. #include "alloc.h"
  17. char *
  18. Realloc(ptr, sz)
  19. char ptr[];
  20. unsigned int sz;
  21. {
  22. register char *mptr;
  23. if (!ptr) mptr = malloc(sz);
  24. else mptr = realloc(ptr, sz);
  25. if (sz && mptr == 0) No_Mem();
  26. return mptr;
  27. }