Index: include/private/SkTemplates.h |
diff --git a/include/private/SkTemplates.h b/include/private/SkTemplates.h |
index 8850a29a63653798d03af5313fb6622bdba34820..526c307558c6a98db262d54ef37bc5548af69f14 100644 |
--- a/include/private/SkTemplates.h |
+++ b/include/private/SkTemplates.h |
@@ -96,6 +96,7 @@ |
SkAutoTDelete(T* obj = NULL) : std::unique_ptr<T>(obj) {} |
operator T*() const { return this->get(); } |
+ void free() { this->reset(nullptr); } |
// See SkAutoTUnref for why we do this. |
explicit operator bool() const { return this->get() != nullptr; } |
@@ -104,6 +105,8 @@ |
template <typename T> class SkAutoTDeleteArray : public std::unique_ptr<T[]> { |
public: |
SkAutoTDeleteArray(T array[]) : std::unique_ptr<T[]>(array) {} |
+ |
+ void free() { this->reset(nullptr); } |
}; |
/** Allocate an array of T elements, and free the array in the destructor |
@@ -278,9 +281,9 @@ |
} |
/** Resize the memory area pointed to by the current ptr without preserving contents. */ |
- T* reset(size_t count = 0) { |
+ T* reset(size_t count) { |
sk_free(fPtr); |
- fPtr = count ? (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW) : nullptr; |
+ fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW); |
return fPtr; |
} |
@@ -300,6 +303,13 @@ |
const T& operator[](int index) const { |
return fPtr[index]; |
+ } |
+ |
+ /** |
+ * Releases the block back to the heap |
+ */ |
+ void free() { |
+ this->reset(0); |
} |
/** |