home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff218.lzh / EdLib / strdup.c < prev    next >
C/C++ Source or Header  |  1989-06-04  |  434b  |  28 lines

  1. /*
  2.  * edlib v1.1 Copyright 1989 Edwin Hoogerbeets
  3.  * This code is freely redistributable as long as no charge other than
  4.  * reasonable copying fees are levied for it.
  5.  */
  6. #include <errno.h>
  7.  
  8. #define NULL 0L
  9. extern char *malloc();
  10.  
  11. char *strdup(str)
  12. register char *str;
  13. {
  14.   register char *dup = malloc(strlen(str));
  15.  
  16.   if ( !dup ) {
  17.     errno = ENOMEM;
  18.     return(NULL);
  19.   }
  20.  
  21.   if ( dup ) {
  22.     strcat(dup,str);
  23.   }
  24.  
  25.   return(dup);
  26. }
  27.  
  28.