aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private/SkTemplates.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/private/SkTemplates.h')
-rw-r--r--include/private/SkTemplates.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/private/SkTemplates.h b/include/private/SkTemplates.h
index 533cb264d1..c1fd4cbca6 100644
--- a/include/private/SkTemplates.h
+++ b/include/private/SkTemplates.h
@@ -272,9 +272,10 @@ public:
}
/** Resize the memory area pointed to by the current ptr without preserving contents. */
- void reset(size_t count) {
+ T* reset(size_t count) {
sk_free(fPtr);
fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW);
+ return fPtr;
}
T* get() const { return fPtr; }
@@ -296,6 +297,13 @@ public:
}
/**
+ * Releases the block back to the heap
+ */
+ void free() {
+ this->reset(0);
+ }
+
+ /**
* Transfer ownership of the ptr to the caller, setting the internal
* pointer to NULL. Note that this differs from get(), which also returns
* the pointer, but it does not transfer ownership.