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

Unified Diff: include/core/SkLazyPtr.h

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 4 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/SkImageEncoder.h ('k') | include/core/SkPathEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkLazyPtr.h
diff --git a/include/core/SkLazyPtr.h b/include/core/SkLazyPtr.h
index 035a269addbd162562d0c62ea195b333e4ece583..b0cd2ff559d6061de52f72c5c8882be8f5087376 100644
--- a/include/core/SkLazyPtr.h
+++ b/include/core/SkLazyPtr.h
@@ -13,12 +13,12 @@
* Example usage:
*
* Foo* GetSingletonFoo() {
- * SK_DECLARE_STATIC_LAZY_PTR(Foo, singleton); // Created with SkNEW, destroyed with SkDELETE.
+ * SK_DECLARE_STATIC_LAZY_PTR(Foo, singleton); // Created with new, destroyed with delete.
* return singleton.get();
* }
*
* These macros take an optional T* (*Create)() and void (*Destroy)(T*) at the end.
- * If not given, we'll use SkNEW and SkDELETE.
+ * If not given, we'll use new and delete.
* These options are most useful when T doesn't have a public constructor or destructor.
* Create comes first, so you may use a custom Create with a default Destroy, but not vice versa.
*
@@ -86,8 +86,14 @@ static P try_cas(P* dst, P ptr) {
}
}
-template <typename T> T* sk_new() { return SkNEW(T); }
-template <typename T> void sk_delete(T* ptr) { SkDELETE(ptr); }
+template <typename T>
+T* sk_new() {
+ return new T;
+}
+template <typename T>
+void sk_delete(T* ptr) {
+ delete ptr;
+}
// We're basing these implementations here on this article:
// http://preshing.com/20140709/the-purpose-of-memory_order_consume-in-cpp11/
@@ -128,7 +134,10 @@ private:
T* fPtr;
};
-template <typename T> T* sk_new_arg(int i) { return SkNEW_ARGS(T, (i)); }
+template <typename T>
+T* sk_new_arg(int i) {
+ return new T(i);
+}
// This has no constructor and must be zero-initalized (the macro above does this).
template <typename T, int N, T* (*Create)(int) = sk_new_arg<T>, void (*Destroy)(T*) = sk_delete<T> >
@@ -162,7 +171,7 @@ public:
T* get() const {
T* ptr = Private::consume_load(&fPtr);
- return ptr ? ptr : Private::try_cas<T*, Destroy>(&fPtr, SkNEW(T));
+ return ptr ? ptr : Private::try_cas<T*, Destroy>(&fPtr, new T);
}
template <typename Create>
« no previous file with comments | « include/core/SkImageEncoder.h ('k') | include/core/SkPathEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698