]> pd.if.org Git - zos/blob - klib/strdup.c
klib and makefile
[zos] / klib / strdup.c
1 #include <string.h>\r
2 #include <stdlib.h>\r
3 \r
4 char *strdup(const char *s) {\r
5         char *ns = NULL;\r
6         size_t len;\r
7 \r
8         if (s) {\r
9                 len = strlen(s) + 1;\r
10                 ns = malloc(len);\r
11                 if (ns)\r
12                         strncpy(ns, s, len);\r
13         }\r
14         return ns;\r
15 }\r