summaryrefslogtreecommitdiff
path: root/klibc/klibc/strdup.c
blob: eb170c2645dd53910cb0021b3601ec206e3087dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
 * strdup.c
 */

#include <string.h>
#include <stdlib.h>

char *strdup(const char *s)
{
  int l = strlen(s)+1;
  char *d = malloc(l);

  if ( d )
    memcpy(d, s, l);

  return d;
}