xref: /optee_os/lib/libutils/isoc/strdup.c (revision 9d7dd4194b5a3e47509ce1cd19824095e620ef51)
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