1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC. 2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3cb93a386Sopenharmony_ci 4cb93a386Sopenharmony_ci#include "include/private/SkMalloc.h" 5cb93a386Sopenharmony_ci 6cb93a386Sopenharmony_ci#include "src/core/SkSafeMath.h" 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_civoid* sk_calloc_throw(size_t count, size_t elemSize) { 9cb93a386Sopenharmony_ci return sk_calloc_throw(SkSafeMath::Mul(count, elemSize)); 10cb93a386Sopenharmony_ci} 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_civoid* sk_malloc_throw(size_t count, size_t elemSize) { 13cb93a386Sopenharmony_ci return sk_malloc_throw(SkSafeMath::Mul(count, elemSize)); 14cb93a386Sopenharmony_ci} 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_civoid* sk_realloc_throw(void* buffer, size_t count, size_t elemSize) { 17cb93a386Sopenharmony_ci return sk_realloc_throw(buffer, SkSafeMath::Mul(count, elemSize)); 18cb93a386Sopenharmony_ci} 19cb93a386Sopenharmony_ci 20cb93a386Sopenharmony_civoid* sk_malloc_canfail(size_t count, size_t elemSize) { 21cb93a386Sopenharmony_ci return sk_malloc_canfail(SkSafeMath::Mul(count, elemSize)); 22cb93a386Sopenharmony_ci} 23