1 /* [XSI] char* strdup(const char *)
\r
3 This file is part of the Public Domain C Library (PDCLib).
\r
4 Permission is granted to use, modify, and / or redistribute at will.
\r
12 char *strdup(const char *s)
\r
16 size_t len = strlen(s) + 1;
\r
19 strncpy(ns, s, len);
\r
27 #include <_PDCLIB_test.h>
\r
31 const char *teststr = "Hello, world";
\r
32 const char *teststr2 = "An alternative test string with non-7-bit characters \xFE\x8C\n";
\r
33 char *testres, *testres2;
\r
35 TESTCASE(testres = strdup(teststr));
\r
36 TESTCASE(testres2 = strdup(teststr2));
\r
37 TESTCASE(strcmp(testres, teststr) == 0);
\r
38 TESTCASE(strcmp(testres2, teststr2) == 0);
\r
42 return TEST_RESULTS;
\r