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

Unified Diff: include/private/SkTemplates.h

Issue 1811723002: free -> reset (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: zarro boogs found Created 4 years, 9 months 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/core/SkTypes.h ('k') | src/codec/SkBmpCodec.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 526c307558c6a98db262d54ef37bc5548af69f14..8850a29a63653798d03af5313fb6622bdba34820 100644
--- a/include/private/SkTemplates.h
+++ b/include/private/SkTemplates.h
@@ -96,7 +96,6 @@ public:
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; }
@@ -105,8 +104,6 @@ public:
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
@@ -281,9 +278,9 @@ public:
}
/** Resize the memory area pointed to by the current ptr without preserving contents. */
- T* reset(size_t count) {
+ T* reset(size_t count = 0) {
sk_free(fPtr);
- fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW);
+ fPtr = count ? (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW) : nullptr;
return fPtr;
}
@@ -306,13 +303,6 @@ 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/core/SkTypes.h ('k') | src/codec/SkBmpCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698