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 strdup(const char * s)8char *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