File: strdup.c

package info (click to toggle)
leafnode 1.11.2.rel-1.0sarge0
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,284 kB
  • ctags: 572
  • sloc: ansic: 10,540; sh: 4,154; xml: 636; makefile: 266; perl: 84; sed: 4
file content (12 lines) | stat: -rw-r--r-- 191 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
#include <string.h>
#include <stdlib.h>

char *
strdup(const char *s)
{
    char *s1;
    s1 = malloc(strlen(s) + 1);
    if (s1 != NULL)
	strcpy(s1, s);		/* RATS: ignore */
    return s1;
}