xref: /aosp_15_r20/external/skia/src/base/SkSafeMath.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2023 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "src/base/SkSafeMath.h"
9 
Add(size_t x,size_t y)10 size_t SkSafeMath::Add(size_t x, size_t y) {
11     SkSafeMath tmp;
12     size_t sum = tmp.add(x, y);
13     return tmp.ok() ? sum : SIZE_MAX;
14 }
15 
Mul(size_t x,size_t y)16 size_t SkSafeMath::Mul(size_t x, size_t y) {
17     SkSafeMath tmp;
18     size_t prod = tmp.mul(x, y);
19     return tmp.ok() ? prod : SIZE_MAX;
20 }
21