strdup.c 270 B

12345678910111213141516171819
  1. /*
  2. * Platforms without strdup ?!?!?!
  3. */
  4. static char *
  5. strdup( char const *s )
  6. {
  7. char *cp;
  8. if (s == NULL)
  9. return NULL;
  10. cp = (char *) AGALOC((unsigned) (strlen(s)+1), "strdup");
  11. if (cp != NULL)
  12. (void) strcpy(cp, s);
  13. return cp;
  14. }