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

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: 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 | no next file » | 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..3ca5978cbb5578561e59db28b5e123d57b6bf23f 100644
--- a/include/private/SkTemplates.h
+++ b/include/private/SkTemplates.h
@@ -326,8 +326,11 @@ 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 > 0) {
fPtr = fTStorage;
+ } else {
+ SkASSERT(0 == count);
reed1 2016/06/22 11:33:30 Can this ever not be true?
csmartdalton 2016/06/23 17:07:46 The idea would be that if somebody unintentionally
reed1 2016/06/23 17:44:36 but count is size_t, which will never appear to be
csmartdalton 2016/06/23 18:07:26 Yeah, I realized it was size_t after the fact :)
+ fPtr = nullptr;
}
}
@@ -344,8 +347,11 @@ public:
}
if (count > kCount) {
fPtr = (T*)sk_malloc_throw(count * sizeof(T));
- } else {
+ } else if (count > 0) {
fPtr = fTStorage;
+ } else {
+ SkASSERT(0 == count);
+ fPtr = nullptr;
}
return fPtr;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698