aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private/SkTArray.h
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-01-05 11:20:10 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-05 21:29:35 +0000
commit8dc8dbc8211e7b0245a6e7db911265efbe0fccaf (patch)
treef112c74f618a536e86a80d9d657b804a039f3f54 /include/private/SkTArray.h
parentf21b32ccd7bd174ce647078854b2314f8b64d94c (diff)
begin cleanup of malloc porting layer
1. Merge some of the allocators into sk_malloc_flags by redefining a flag to mean zero-init 2. Add more private helpers to simplify our call-sites (and handle some overflow mul checks) 3. The 2-param helpers rely on the saturating SkSafeMath::Mul to pass max_size_t as the request, which should always fail. Bug:508641 Change-Id: I322f1e6ed91113467e0fdb12c91c3dad33d890c8 Reviewed-on: https://skia-review.googlesource.com/90940 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Stephan Altmueller <stephana@google.com>
Diffstat (limited to 'include/private/SkTArray.h')
-rw-r--r--include/private/SkTArray.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/private/SkTArray.h b/include/private/SkTArray.h
index 3f4cc429b4..68dab9a33a 100644
--- a/include/private/SkTArray.h
+++ b/include/private/SkTArray.h
@@ -445,7 +445,7 @@ private:
fReserved = false;
} else {
fAllocCount = SkTMax(count, SkTMax(kMinHeapAllocCount, reserveCount));
- fMemArray = sk_malloc_throw(fAllocCount * sizeof(T));
+ fMemArray = sk_malloc_throw(fAllocCount, sizeof(T));
fOwnMemory = true;
fReserved = reserveCount > 0;
}
@@ -460,7 +460,7 @@ private:
fReserved = false;
if (count > preallocCount) {
fAllocCount = SkTMax(count, kMinHeapAllocCount);
- fMemArray = sk_malloc_throw(fAllocCount * sizeof(T));
+ fMemArray = sk_malloc_throw(fAllocCount, sizeof(T));
fOwnMemory = true;
} else {
fAllocCount = preallocCount;
@@ -537,7 +537,7 @@ private:
return;
}
fAllocCount = newAllocCount;
- void* newMemArray = sk_malloc_throw(fAllocCount * sizeof(T));
+ void* newMemArray = sk_malloc_throw(fAllocCount, sizeof(T));
this->move(newMemArray);
if (fOwnMemory) {
sk_free(fMemArray);