OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkTLS.h" | 8 #include "SkTLS.h" |
9 | 9 |
10 // enable to help debug TLS storage | 10 // enable to help debug TLS storage |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 }; | 43 }; |
44 | 44 |
45 void SkTLS::Destructor(void* ptr) { | 45 void SkTLS::Destructor(void* ptr) { |
46 #ifdef SK_TRACE_TLS_LIFETIME | 46 #ifdef SK_TRACE_TLS_LIFETIME |
47 SkDebugf("SkTLS::Destructor(%p)\n", ptr); | 47 SkDebugf("SkTLS::Destructor(%p)\n", ptr); |
48 #endif | 48 #endif |
49 | 49 |
50 SkTLSRec* rec = (SkTLSRec*)ptr; | 50 SkTLSRec* rec = (SkTLSRec*)ptr; |
51 do { | 51 do { |
52 SkTLSRec* next = rec->fNext; | 52 SkTLSRec* next = rec->fNext; |
53 SkDELETE(rec); | 53 delete rec; |
54 rec = next; | 54 rec = next; |
55 } while (rec); | 55 } while (rec); |
56 } | 56 } |
57 | 57 |
58 void* SkTLS::Get(CreateProc createProc, DeleteProc deleteProc) { | 58 void* SkTLS::Get(CreateProc createProc, DeleteProc deleteProc) { |
59 if (NULL == createProc) { | 59 if (NULL == createProc) { |
60 return NULL; | 60 return NULL; |
61 } | 61 } |
62 | 62 |
63 void* ptr = SkTLS::PlatformGetSpecific(true); | 63 void* ptr = SkTLS::PlatformGetSpecific(true); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 SkTLSRec* prev = NULL; | 114 SkTLSRec* prev = NULL; |
115 while (curr) { | 115 while (curr) { |
116 SkTLSRec* next = curr->fNext; | 116 SkTLSRec* next = curr->fNext; |
117 if (curr->fCreateProc == createProc) { | 117 if (curr->fCreateProc == createProc) { |
118 if (prev) { | 118 if (prev) { |
119 prev->fNext = next; | 119 prev->fNext = next; |
120 } else { | 120 } else { |
121 // we have a new head of our chain | 121 // we have a new head of our chain |
122 SkTLS::PlatformSetSpecific(next); | 122 SkTLS::PlatformSetSpecific(next); |
123 } | 123 } |
124 SkDELETE(curr); | 124 delete curr; |
125 break; | 125 break; |
126 } | 126 } |
127 prev = curr; | 127 prev = curr; |
128 curr = next; | 128 curr = next; |
129 } | 129 } |
130 } | 130 } |
OLD | NEW |