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 #ifndef SkTLList_DEFINED | 8 #ifndef SkTLList_DEFINED |
9 #define SkTLList_DEFINED | 9 #define SkTLList_DEFINED |
10 | 10 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 }; | 240 }; |
241 | 241 |
242 size_t blockSize() const { return sizeof(Block) + sizeof(Node) * (fAllocCnt-
1); } | 242 size_t blockSize() const { return sizeof(Block) + sizeof(Node) * (fAllocCnt-
1); } |
243 | 243 |
244 Node* createNode() { | 244 Node* createNode() { |
245 Node* node = fFreeList.head(); | 245 Node* node = fFreeList.head(); |
246 if (node) { | 246 if (node) { |
247 fFreeList.remove(node); | 247 fFreeList.remove(node); |
248 ++node->fBlock->fNodesInUse; | 248 ++node->fBlock->fNodesInUse; |
249 } else { | 249 } else { |
250 Block* block = reinterpret_cast<Block*>(sk_malloc_flags(this->blockS
ize(), 0)); | 250 Block* block = reinterpret_cast<Block*>(sk_malloc_throw(this->blockS
ize())); |
251 node = &block->fNodes[0]; | 251 node = &block->fNodes[0]; |
252 new (node) Node; | 252 new (node) Node; |
253 node->fBlock = block; | 253 node->fBlock = block; |
254 block->fNodesInUse = 1; | 254 block->fNodesInUse = 1; |
255 for (int i = 1; i < fAllocCnt; ++i) { | 255 for (int i = 1; i < fAllocCnt; ++i) { |
256 new (block->fNodes + i) Node; | 256 new (block->fNodes + i) Node; |
257 fFreeList.addToHead(block->fNodes + i); | 257 fFreeList.addToHead(block->fNodes + i); |
258 block->fNodes[i].fBlock = block; | 258 block->fNodes[i].fBlock = block; |
259 } | 259 } |
260 } | 260 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 #define SkNEW_INSERT_IN_LLIST_AFTER(list, location, type_name, args) \ | 394 #define SkNEW_INSERT_IN_LLIST_AFTER(list, location, type_name, args) \ |
395 (new ((list), SkTLList< type_name >::kAfter_Placement, (location)) type_name
args) | 395 (new ((list), SkTLList< type_name >::kAfter_Placement, (location)) type_name
args) |
396 | 396 |
397 #define SkNEW_INSERT_AT_LLIST_HEAD(list, type_name, args) \ | 397 #define SkNEW_INSERT_AT_LLIST_HEAD(list, type_name, args) \ |
398 SkNEW_INSERT_IN_LLIST_BEFORE((list), (list)->headIter(), type_name, args) | 398 SkNEW_INSERT_IN_LLIST_BEFORE((list), (list)->headIter(), type_name, args) |
399 | 399 |
400 #define SkNEW_INSERT_AT_LLIST_TAIL(list, type_name, args) \ | 400 #define SkNEW_INSERT_AT_LLIST_TAIL(list, type_name, args) \ |
401 SkNEW_INSERT_IN_LLIST_AFTER((list), (list)->tailIter(), type_name, args) | 401 SkNEW_INSERT_IN_LLIST_AFTER((list), (list)->tailIter(), type_name, args) |
402 | 402 |
403 #endif | 403 #endif |
OLD | NEW |