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

Unified Diff: src/core/SkTemplatesPriv.h

Issue 155513012: [WIP] Add Context to SkDrawLooper. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comments. Created 6 years, 10 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
Index: src/core/SkTemplatesPriv.h
diff --git a/src/core/SkTemplatesPriv.h b/src/core/SkTemplatesPriv.h
index 79ae6093358993917df7cf3261ef4be93a6063e8..c7d61da7cf80e917e5708774b8f43c22763725db 100644
--- a/src/core/SkTemplatesPriv.h
+++ b/src/core/SkTemplatesPriv.h
@@ -20,6 +20,12 @@
#define SK_PLACEMENT_NEW_ARGS(result, classname, storage, storageSize, args) \
result = SkNEW_ARGS(classname, args)
+
+ #define SK_PLACEMENT_SAFE_NEW(result, classname, storage, storageSize) \
+ result = SkNEW(classname)
scroggo 2014/02/11 15:51:29 Yikes! This will result in a memory leak if the ca
Dominik Grewe 2014/02/11 16:04:31 I guess the same is true for the normal placement
scroggo 2014/02/11 16:14:26 Well, this one is actually safer than the normal p
+
+ #define SK_PLACEMENT_SAFE_NEW_ARGS(result, classname, storage, storageSize, args) \
+ result = SkNEW_ARGS(classname, args)
#else
#include <new>
#define SK_PLACEMENT_NEW(result, classname, storage, storagesize) \
bungeman-skia 2014/02/11 17:06:21 Every current user of this does the same dance whe
@@ -43,6 +49,22 @@
else \
result = SkNEW_ARGS(classname, args); \
} while (0)
+
+ #define SK_PLACEMENT_SAFE_NEW(result, classname, storage, storagesize) \
bungeman-skia 2014/02/11 17:06:21 Why are we multiplying entities without necessity
+ do { \
+ if (storagesize >= sizeof(classname)) \
+ result = new(storage) classname; \
+ else \
+ result = SkNEW(classname); \
+ } while (0)
+
+ #define SK_PLACEMENT_SAFE_NEW_ARGS(result, classname, storage, storagesize, args) \
+ do { \
+ if (storagesize >= sizeof(classname)) \
+ result = new(storage) classname args; \
+ else \
+ result = SkNEW_ARGS(classname, args); \
+ } while (0)
#endif
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698