home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / UUCPbb_2_1_src.lzh / UUCPBB21 / strdup.c < prev    next >
Text File  |  1994-09-25  |  500b  |  21 lines

  1. /* Returns a pointer to the string copy if successful.  Returns a NULL if
  2.    malloc() can't get enough memory.   --REB */
  3.  
  4. #include "uucp.h"
  5.  
  6.  
  7. char *strdup (string)
  8. register char *string;
  9. {
  10.      char *dup;
  11.  
  12.      /* grab some memory for the string, don't forget the ending NULL */
  13.      dup = (char *)malloc ((strlen (string) + 1) * sizeof (char));
  14.  
  15.      /* copy the string and return a pointer to it if malloc() succeeded */
  16.      if (dup != NULL)
  17.           strcpy (dup, string);
  18.  
  19.      return (dup);
  20. }
  21.