Lines 169-181
Link Here
|
169 |
} |
169 |
} |
170 |
|
170 |
|
171 |
static inline struct pthread_specific_elem * |
171 |
static inline struct pthread_specific_elem * |
172 |
pthread_key_allocate_data(void) |
172 |
pthread_key_allocate_data(struct pthread *pthread) |
173 |
{ |
173 |
{ |
174 |
struct pthread_specific_elem *new_data; |
174 |
struct pthread_specific_elem *new_data; |
175 |
|
175 |
|
176 |
new_data = (struct pthread_specific_elem *) |
176 |
new_data = (struct pthread_specific_elem *) |
177 |
calloc(1, sizeof(struct pthread_specific_elem) * PTHREAD_KEYS_MAX); |
177 |
calloc(1, sizeof(struct pthread_specific_elem) * PTHREAD_KEYS_MAX); |
178 |
return (new_data); |
178 |
if (!pthread->specific) |
|
|
179 |
pthread->specific = new_data; |
180 |
else /* some malloc libraries may call pthread_setspecific themselves */ |
181 |
free(new_data); |
182 |
|
183 |
return (pthread->specific); |
179 |
} |
184 |
} |
180 |
|
185 |
|
181 |
int |
186 |
int |
Lines 189-195
Link Here
|
189 |
pthread = _get_curthread(); |
194 |
pthread = _get_curthread(); |
190 |
|
195 |
|
191 |
if ((pthread->specific) || |
196 |
if ((pthread->specific) || |
192 |
(pthread->specific = pthread_key_allocate_data())) { |
197 |
(pthread_key_allocate_data(pthread))) { |
193 |
if ((unsigned int)key < PTHREAD_KEYS_MAX) { |
198 |
if ((unsigned int)key < PTHREAD_KEYS_MAX) { |
194 |
if (_thread_keytable[key].allocated) { |
199 |
if (_thread_keytable[key].allocated) { |
195 |
if (pthread->specific[key].data == NULL) { |
200 |
if (pthread->specific[key].data == NULL) { |