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

Unified Diff: include/core/SkTemplates.h

Issue 15739013: Use macros for new and delete in SkTemplates.h (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 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/SkPostConfig.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTemplates.h
diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h
index 5eb7885425f46c31389be142bfeb81e93acdfecb..e89c355ce5efd7633fe0064f0443a1dcc936fa32 100644
--- a/include/core/SkTemplates.h
+++ b/include/core/SkTemplates.h
@@ -101,7 +101,7 @@ private:
template <typename T> class SkAutoTDelete : SkNoncopyable {
public:
SkAutoTDelete(T* obj = NULL) : fObj(obj) {}
- ~SkAutoTDelete() { delete fObj; }
+ ~SkAutoTDelete() { SkDELETE(fObj); }
T* get() const { return fObj; }
T& operator*() const { SkASSERT(fObj); return *fObj; }
@@ -109,7 +109,7 @@ public:
void reset(T* obj) {
if (fObj != obj) {
- delete fObj;
+ SkDELETE(fObj);
fObj = obj;
}
}
@@ -118,7 +118,7 @@ public:
* Delete the owned object, setting the internal pointer to NULL.
*/
void free() {
- delete fObj;
+ SkDELETE(fObj);
fObj = NULL;
}
@@ -182,7 +182,7 @@ public:
SkASSERT(count >= 0);
fArray = NULL;
if (count) {
- fArray = new T[count];
+ fArray = SkNEW_ARRAY(T, count);
}
SkDEBUGCODE(fCount = count;)
}
@@ -190,17 +190,17 @@ public:
/** Reallocates given a new count. Reallocation occurs even if new count equals old count.
*/
void reset(int count) {
- delete[] fArray;
+ SkDELETE_ARRAY(fArray);
SkASSERT(count >= 0);
fArray = NULL;
if (count) {
- fArray = new T[count];
+ fArray = SkNEW_ARRAY(T, count);
}
SkDEBUGCODE(fCount = count;)
}
~SkAutoTArray() {
- delete[] fArray;
+ SkDELETE_ARRAY(fArray);
}
/** Return the array of T elements. Will be NULL if count == 0
@@ -227,9 +227,9 @@ public:
*/
SkAutoSTArray(size_t count) {
if (count > N) {
- fArray = new T[count];
+ fArray = SkNEW_ARRAY(T, count);
} else if (count) {
- fArray = new (fStorage) T[count];
bungeman-skia 2013/05/25 03:22:07 I think this is a bug. You can never be sure how m
+ fArray = SkNEW_PLACEMENT_ARRAY(fStorage, T, count);
} else {
fArray = NULL;
}
@@ -238,7 +238,7 @@ public:
~SkAutoSTArray() {
if (fCount > N) {
- delete[] fArray;
+ SkDELETE_ARRAY(fArray);
} else {
T* start = fArray;
T* iter = start + fCount;
« no previous file with comments | « include/core/SkPostConfig.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698