OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 SkTypes_DEFINED | 8 #ifndef SkTypes_DEFINED |
9 #define SkTypes_DEFINED | 9 #define SkTypes_DEFINED |
10 | 10 |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 SkAutoFree(const SkAutoFree&); | 479 SkAutoFree(const SkAutoFree&); |
480 SkAutoFree& operator=(const SkAutoFree&); | 480 SkAutoFree& operator=(const SkAutoFree&); |
481 }; | 481 }; |
482 #define SkAutoFree(...) SK_REQUIRE_LOCAL_VAR(SkAutoFree) | 482 #define SkAutoFree(...) SK_REQUIRE_LOCAL_VAR(SkAutoFree) |
483 | 483 |
484 /** | 484 /** |
485 * Manage an allocated block of heap memory. This object is the sole manager of | 485 * Manage an allocated block of heap memory. This object is the sole manager of |
486 * the lifetime of the block, so the caller must not call sk_free() or delete | 486 * the lifetime of the block, so the caller must not call sk_free() or delete |
487 * on the block, unless detach() was called. | 487 * on the block, unless detach() was called. |
488 */ | 488 */ |
489 class SkAutoMalloc : public SkNoncopyable { | 489 class SkAutoMalloc : SkNoncopyable { |
490 public: | 490 public: |
491 explicit SkAutoMalloc(size_t size = 0) { | 491 explicit SkAutoMalloc(size_t size = 0) { |
492 fPtr = size ? sk_malloc_throw(size) : NULL; | 492 fPtr = size ? sk_malloc_throw(size) : NULL; |
493 fSize = size; | 493 fSize = size; |
494 } | 494 } |
495 | 495 |
496 ~SkAutoMalloc() { | 496 ~SkAutoMalloc() { |
497 sk_free(fPtr); | 497 sk_free(fPtr); |
498 } | 498 } |
499 | 499 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 private: | 651 private: |
652 void* fPtr; | 652 void* fPtr; |
653 size_t fSize; // can be larger than the requested size (see kReuse) | 653 size_t fSize; // can be larger than the requested size (see kReuse) |
654 uint32_t fStorage[(kSize + 3) >> 2]; | 654 uint32_t fStorage[(kSize + 3) >> 2]; |
655 }; | 655 }; |
656 // Can't guard the constructor because it's a template class. | 656 // Can't guard the constructor because it's a template class. |
657 | 657 |
658 #endif /* C++ */ | 658 #endif /* C++ */ |
659 | 659 |
660 #endif | 660 #endif |
OLD | NEW |