OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkTemplates_DEFINED | 10 #ifndef SkTemplates_DEFINED |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 T* detach() { | 362 T* detach() { |
363 T* ptr = fPtr; | 363 T* ptr = fPtr; |
364 fPtr = NULL; | 364 fPtr = NULL; |
365 return ptr; | 365 return ptr; |
366 } | 366 } |
367 | 367 |
368 private: | 368 private: |
369 T* fPtr; | 369 T* fPtr; |
370 }; | 370 }; |
371 | 371 |
372 template <size_t N, typename T> class SK_API SkAutoSTMalloc : SkNoncopyable { | 372 template <size_t N, typename T> class SkAutoSTMalloc : SkNoncopyable { |
373 public: | 373 public: |
374 SkAutoSTMalloc() { | 374 SkAutoSTMalloc() { |
375 fPtr = NULL; | 375 fPtr = NULL; |
376 } | 376 } |
377 | 377 |
378 SkAutoSTMalloc(size_t count) { | 378 SkAutoSTMalloc(size_t count) { |
379 if (count > N) { | 379 if (count > N) { |
380 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_M
ALLOC_TEMP); | 380 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_M
ALLOC_TEMP); |
381 } else if (count) { | 381 } else if (count) { |
382 fPtr = fTStorage; | 382 fPtr = fTStorage; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 /** | 458 /** |
459 * Returns void* because this object does not initialize the | 459 * Returns void* because this object does not initialize the |
460 * memory. Use placement new for types that require a cons. | 460 * memory. Use placement new for types that require a cons. |
461 */ | 461 */ |
462 void* get() { return fStorage.get(); } | 462 void* get() { return fStorage.get(); } |
463 private: | 463 private: |
464 SkAlignedSStorage<sizeof(T)*N> fStorage; | 464 SkAlignedSStorage<sizeof(T)*N> fStorage; |
465 }; | 465 }; |
466 | 466 |
467 #endif | 467 #endif |
OLD | NEW |