X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fthread%2Fpthread_setspecific.c;h=55e46a899378f4f896e570ad8edbacbe569cbcf8;hp=171cef41e8305173d00c3aea7a0377a7d614aed2;hb=d960d4f2cbf18ff3476c7ac03698ec253885dd8e;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 diff --git a/src/thread/pthread_setspecific.c b/src/thread/pthread_setspecific.c index 171cef41..55e46a89 100644 --- a/src/thread/pthread_setspecific.c +++ b/src/thread/pthread_setspecific.c @@ -2,13 +2,7 @@ int pthread_setspecific(pthread_key_t k, const void *x) { - struct pthread *self = pthread_self(); - /* Handle the case of the main thread */ - if (!self->tsd) { - if (!x) return 0; - if (!(self->tsd = calloc(sizeof(void *), PTHREAD_KEYS_MAX))) - return ENOMEM; - } + struct pthread *self = __pthread_self(); /* Avoid unnecessary COW */ if (self->tsd[k] != x) { self->tsd[k] = (void *)x;