home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / stex2-18.zip / SeeTeX / libtex / strsave.c < prev    next >
C/C++ Source or Header  |  1990-07-10  |  587b  |  30 lines

  1. /*
  2.  * Copyright (c) 1987, 1989 University of Maryland
  3.  * Department of Computer Science.  All rights reserved.
  4.  * Permission to copy for any purpose is hereby granted
  5.  * so long as this copyright notice remains intact.
  6.  */
  7.  
  8. /*
  9.  * Save a string in managed memory.
  10.  */
  11.  
  12. char    *malloc(), *realloc();
  13. extern int errno;
  14.  
  15. #include "types.h"        /* for bcopy */
  16. #include "error.h"
  17.  
  18. char *
  19. strsave(s)
  20.     register char *s;
  21. {
  22.     register int l = strlen(s) + 1;
  23.     register char *p = malloc((unsigned) l);
  24.  
  25.     if (p == 0)
  26.         error(1, errno, "no room for %d bytes of string", l);
  27.     bcopy(s, p, l);
  28.     return (p);
  29. }
  30.