xref: /optee_os/lib/libutils/isoc/strdup.c (revision 9f34db38245c9b3a4e6e7e63eb78a75e23ab2da3)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (c) 2014, STMicroelectronics International N.V.
4  */
5 #include <stdlib.h>
6 #include <string.h>
7 
8 char *strdup(const char *s)
9 {
10 	size_t l = strlen(s) + 1;
11 	char *p = malloc(l);
12 
13 	if (p)
14 		memcpy(p, s, l);
15 	return p;
16 }
17