home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GERLIB_DEV08B.LHA / gerlib / string / normal / strdup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-12  |  230 b   |  14 lines

  1. #include <sys/types.h>
  2. extern void *malloc(size_t size);
  3.  
  4. char *
  5. strdup(s)
  6.      char *s;
  7. {
  8.     char *result = (char*)malloc(strlen(s) + 1);
  9.     if (result == (char*)0)
  10.     return (char*)0;
  11.     strcpy(result, s);
  12.     return result;
  13. }
  14.