static stubs_state_t* __stubs_state() { pthread_once(&stubs_once, __stubs_key_init); stubs_state_t* s = static_cast<stubs_state_t*>(pthread_getspecific(stubs_key)); if (s == NULL) { s = stubs_state_alloc(); if (s == NULL) { errno = ENOMEM; // Just in case. } else { if (pthread_setspecific(stubs_key, s) != 0) { stubs_state_free(s); errno = ENOMEM; s = NULL; } } } return s; }
static stubs_state_t* __stubs_state(void) { stubs_state_t* s; pthread_once(&the_once, __stubs_key_init); s = pthread_getspecific(the_key); if (s == NULL) { s = stubs_state_alloc(); if (s == NULL) { errno = ENOMEM; /* just in case */ } else { if ( pthread_setspecific(the_key, s) != 0 ) { stubs_state_free(s); errno = ENOMEM; s = NULL; } } } return s; }