Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
safe_math.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_FML_SAFE_MATH_H_
6#define FLUTTER_FML_SAFE_MATH_H_
7
8#include <cstddef>
9#include <cstdint>
10
11namespace fml {
12
13// Math operations that check for overflow.
14// Based on Skia's SkSafeMath.
15class SafeMath {
16 public:
17 bool overflow_detected() const { return overflow_detected_; }
18
19 size_t mul(size_t x, size_t y);
20
21 private:
22 uint32_t mul32(uint32_t x, uint32_t y);
23 uint64_t mul64(uint64_t x, uint64_t y);
24
25 bool overflow_detected_ = false;
26};
27
28} // namespace fml
29
30#endif // FLUTTER_FML_SAFE_MATH_H_
size_t mul(size_t x, size_t y)
Definition safe_math.cc:12
bool overflow_detected() const
Definition safe_math.h:17
int32_t x
double y