home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8712 / mkmf / 2 / src / strsav.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-13  |  519 b   |  26 lines

  1. /* $Header: strsav.c,v 1.1 85/03/14 17:00:30 nicklin Exp $ */
  2.  
  3. /*
  4.  * Author: Peter J. Nicklin
  5.  */
  6.  
  7. /*
  8.  * strsav() saves a string somewhere and returns a pointer to the somewhere.
  9.  * Returns NULL on error.
  10.  */
  11. #include "null.h"
  12.  
  13. char *
  14. strsav(s)
  15.     char *s;
  16. {
  17.     char *sptr;            /* somewhere string pointer */
  18.     char *malloc();            /* memory allocator */
  19.     char *strcpy();            /* string copy */
  20.     int strlen();            /* string length */
  21.  
  22.     if ((sptr = malloc((unsigned)(strlen(s)+1))) == NULL)
  23.         return(NULL);
  24.     return(strcpy(sptr, s));
  25. }
  26.