summaryrefslogtreecommitdiff
path: root/newlib/libc/stdlib/strdup.c
blob: 6261dbbb8f81aad8c18e7a854c24634eeda3bf55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdlib.h>
#include <string.h>

char *
_DEFUN (strdup, (str), _CONST char *str)
{
  size_t len = strlen (str) + 1;
  char *copy = malloc (len);
  if (copy)
    {
      memcpy (copy, str, len);
    }
  return copy;
}