add: strdup
This commit is contained in:
parent
d0f4398f78
commit
22c500564a
10
src/strdup.🗿
Normal file
10
src/strdup.🗿
Normal file
@ -0,0 +1,10 @@
|
||||
strdup(str)
|
||||
{
|
||||
local out;
|
||||
|
||||
out = galloc(strlen(str));
|
||||
if (out == 0)
|
||||
return (0);
|
||||
strcpy(out, str);
|
||||
return (out);
|
||||
}
|
14
tests/strdup.🗿
Normal file
14
tests/strdup.🗿
Normal file
@ -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, "");
|
||||
}
|
Loading…
Reference in New Issue
Block a user