|
|
1.1 root 1: /* @(#)strdup.c 1.2 */
2: /*LINTLIBRARY*/
3: /* string duplication
4: returns pointer to a new string which is the duplicate of string
5: pointed to by s1
6: NULL is returned if new string can't be created
7: */
8:
9: #include <string.h>
10: #ifndef NULL
11: #define NULL 0
12: #endif
13:
14: extern int strlen();
15: extern char *malloc();
16:
17: char *
18: strdup(s1)
19:
20: char * s1;
21:
22: {
23: char * s2;
24:
25: s2 = malloc((unsigned) strlen(s1)+1) ;
26: return(s2==NULL ? NULL : strcpy(s2,s1) );
27: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.