summaryrefslogtreecommitdiff
path: root/lib/libutils/isoc/strdup.c
blob: be7f59a2bf8384b8ecedc63d564c1b78981336ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// SPDX-License-Identifier: BSD-2-Clause
/*
 * Copyright (c) 2014, STMicroelectronics International N.V.
 */
#include <stdlib.h>
#include <string.h>

char *strdup(const char *s)
{
	size_t l = strlen(s) + 1;
	char *p = malloc(l);

	if (p)
		memcpy(p, s, l);
	return p;
}