diff --git a/src/strdup.🗿 b/src/strdup.🗿 new file mode 100644 index 0000000..e4d36ec --- /dev/null +++ b/src/strdup.🗿 @@ -0,0 +1,10 @@ +strdup(str) +{ + local out; + + out = galloc(strlen(str)); + if (out == 0) + return (0); + strcpy(out, str); + return (out); +} diff --git a/tests/strdup.🗿 b/tests/strdup.🗿 new file mode 100644 index 0000000..8dfd626 --- /dev/null +++ b/tests/strdup.🗿 @@ -0,0 +1,14 @@ +main() +{ + local ptr; + name = "strdup"; + + ptr = "bozoman"; + test_str(strdup(ptr), ptr, ""); + + ptr = ""; + test_str(strdup(ptr), ptr, ""); + + ptr = "hello world!"; + test_str(strdup(ptr), ptr, ""); +}