Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(780)

Unified Diff: include/private/SkTemplates.h

Issue 1516833003: Switch SkAutoMalloc to SkAutoTMalloc to avoid cast (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Go back to patch set 3 Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/effects/SkColorCubeFilter.h ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/private/SkTemplates.h
diff --git a/include/private/SkTemplates.h b/include/private/SkTemplates.h
index 533cb264d163ee7354f1e53de7bac4a2de36cd61..c1fd4cbca62e681cdc8e3334ab9338631b7633bf 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.
« no previous file with comments | « include/effects/SkColorCubeFilter.h ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698