strdup.c 182 B

12345678910111213141516
  1. #include <string.h>
  2. #include <ctype.h>
  3. #include <stdlib.h>
  4. char*
  5. strdup(char *p)
  6. {
  7. int n;
  8. char *np;
  9. n = strlen(p)+1;
  10. np = malloc(n);
  11. if(np)
  12. memmove(np, p, n);
  13. return np;
  14. }