fix TLS memory leak with dlopen
[uclibc-ng.git] / libc / string / strsep.c
blobce17dcf89c4b64ee76affb2c3b5955f50ef5b943
1 /*
2 * Copyright (C) 2002 Manuel Novoa III
3 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 */
8 #include "_string.h"
10 #ifdef __USE_BSD
13 char *strsep(char ** __restrict s1, const char * __restrict s2)
15 register char *s = *s1;
16 register char *p;
18 #if 1
19 p = NULL;
20 if (s && *s && (p = strpbrk(s, s2))) {
21 *p++ = 0;
23 #else
24 if (s && *s && *(p = s + strcspn(s, s2))) {
25 *p++ = 0;
26 } else {
27 p = NULL;
29 #endif
30 *s1 = p;
31 return s;
33 libc_hidden_def(strsep)
34 #endif