home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume41 / rperf / part02 / strdup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-19  |  718 b   |  37 lines

  1. #ifndef lint
  2. static char    *RCSid = "$Header: /src/common/usc/lib/libgen/RCS/strdup.c,v 1.2 1992/04/16 01:28:02 mcooper Exp $";
  3. #endif
  4.  
  5. /*
  6.  * $Log: strdup.c,v $ Revision 1.2  1992/04/16  01:28:02  mcooper Some
  7.  * de-linting.
  8.  * 
  9.  * Revision 1.2  1992/04/16  01:28:02  mcooper Some de-linting.
  10.  * 
  11.  * Revision 1.1  1992/03/21  02:48:11  mcooper Initial revision
  12.  * 
  13.  */
  14.  
  15. #include <stdio.h>
  16.  
  17. #ifdef HAVE_STDLIB_H
  18. #include <stdlib.h>
  19. #endif                /* HAVE_STDLIB_H */
  20.  
  21. /*
  22.  * Most systems don't have this (yet)
  23.  */
  24. char           *
  25. strdup(str)
  26.     char           *str;
  27. {
  28.     char           *p;
  29.  
  30.     if ((p = malloc((unsigned) strlen(str) + 1)) == NULL)
  31.     return ((char *) NULL);
  32.  
  33.     (void) strcpy(p, str);
  34.  
  35.     return (p);
  36. }
  37.