home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Python 1.4 / Python 1.4 source / Python / strdup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-14  |  321 b   |  20 lines  |  [TEXT/CWIE]

  1. /* strdup() replacement (from stdwin, if you must know) */
  2.  
  3. #include "config.h"
  4. #include "myproto.h"
  5. #include "mymalloc.h"
  6.  
  7. #include <string.h>
  8.  
  9. char *
  10. strdup(str)
  11.     const char *str;
  12. {
  13.     if (str != NULL) {
  14.         register char *copy = malloc(strlen(str) + 1);
  15.         if (copy != NULL)
  16.             return strcpy(copy, str);
  17.     }
  18.     return NULL;
  19. }
  20.