]> pd.if.org Git - pdclib/blob - platform/win32/functions/threads/tss_delete.c
dos2unix
[pdclib] / platform / win32 / functions / threads / tss_delete.c
1 #ifndef REGTEST
2 #include <windows.h>
3 #include <threads.h>
4 #include <stdlib.h>
5
6 extern struct _PDCLIB_tss * _PDCLIB_tss_first;
7 void tss_delete( tss_t key )
8 {
9     struct _PDCLIB_tss * prev = NULL;
10     struct _PDCLIB_tss * cur  = _PDCLIB_tss_first;
11     while(cur) {
12         if(cur == key) {
13             if(prev) {
14                 prev->_Next = key->_Next;
15             } else {
16                 _PDCLIB_tss_first = key->_Next;
17             }
18
19             TlsFree(key->_Key);
20             free(key);
21             return;
22         }
23     }
24
25     // Not actually a TSS key
26     abort();
27 }
28 #endif
29
30 #ifdef TEST
31 #include "_PDCLIB_test.h"
32
33 /* Tested in tss_get.c */
34 int main( void )
35 {
36     return TEST_RESULTS;
37 }
38
39 #endif