strdup.c 143 B

123456789101112
  1. #include "lib9.h"
  2. char*
  3. strdup(const char *s)
  4. {
  5. char *os;
  6. os = malloc(strlen(s) + 1);
  7. if(os == 0)
  8. return 0;
  9. return strcpy(os, s);
  10. }