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

Unified Diff: include/private/SkTemplates.h

Issue 2084213003: Make container classes in SkTemplates.h more consistent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make buffer classes in SkTemplates.h more consistent Created 4 years, 6 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 | « no previous file | tests/TemplatesTest.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 7e2c19f09daa199486462e0410f64a79a58cce2c..30942ad991675d287785b258cd57324093945e11 100644
--- a/include/private/SkTemplates.h
+++ b/include/private/SkTemplates.h
@@ -209,6 +209,7 @@ public:
} else if (count > 0) {
fArray = (T*) fStorage;
} else {
+ SkASSERT(0 == count);
bsalomon 2016/06/23 17:53:34 I think it'd be slightly clearer to just put SkASS
csmartdalton 2016/06/23 18:07:26 Done.
fArray = NULL;
}
@@ -267,7 +268,7 @@ public:
/** Allocates space for 'count' Ts. */
explicit SkAutoTMalloc(size_t count) {
- fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW);
+ fPtr = count ? (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW) : nullptr;
}
~SkAutoTMalloc() {
@@ -326,8 +327,10 @@ public:
SkAutoSTMalloc(size_t count) {
if (count > kCount) {
fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLOC_TEMP);
- } else {
+ } else if (count) {
fPtr = fTStorage;
+ } else {
+ fPtr = nullptr;
}
}
@@ -344,8 +347,10 @@ public:
}
if (count > kCount) {
fPtr = (T*)sk_malloc_throw(count * sizeof(T));
- } else {
+ } else if (count) {
fPtr = fTStorage;
+ } else {
+ fPtr = nullptr;
}
return fPtr;
}
« no previous file with comments | « no previous file | tests/TemplatesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698