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

Side by Side Diff: fuzz/Fuzz.h

Issue 2446643003: Fix memory leak in FuzzGradients (Closed)
Patch Set: More cleanup Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | fuzz/FuzzGradients.cpp » ('j') | fuzz/FuzzGradients.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef Fuzz_DEFINED 8 #ifndef Fuzz_DEFINED
9 #define Fuzz_DEFINED 9 #define Fuzz_DEFINED
10 10
11 #include "SkData.h" 11 #include "SkData.h"
12 #include "SkTRegistry.h" 12 #include "SkTRegistry.h"
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 14
15 class Fuzz : SkNoncopyable { 15 class Fuzz : SkNoncopyable {
16 public: 16 public:
17 explicit Fuzz(sk_sp<SkData>); 17 explicit Fuzz(sk_sp<SkData>);
18 18
19 // Returns the total number of "random" bytes available. 19 // Returns the total number of "random" bytes available.
20 size_t size(); 20 size_t size();
21 // Returns the total number of "random" bytes remaining for randomness. 21 // Returns the total number of "random" bytes remaining for randomness.
22 size_t remaining(); 22 size_t remaining();
23 23
24 template <typename T> 24 template <typename T>
25 bool next(T* n); 25 bool SK_WARN_UNUSED_RESULT next(T* n);
26 26
27 // UBSAN reminds us that bool can only legally hold 0 or 1. 27 // UBSAN reminds us that bool can only legally hold 0 or 1.
28 bool next(bool* b) { 28 bool SK_WARN_UNUSED_RESULT next(bool* b) {
29 uint8_t byte; 29 uint8_t byte;
30 if (!this->next(&byte)) { 30 if (!this->next(&byte)) {
31 return false; 31 return false;
32 } 32 }
33 *b = (byte & 1) == 1; 33 *b = (byte & 1) == 1;
34 return true; 34 return true;
35 } 35 }
36 36
37 // The nextFoo methods are deprecated. 37 // The nextFoo methods are deprecated.
38 // TODO(kjlubick): replace existing uses with next() and remove these. 38 // TODO(kjlubick): replace existing uses with next() and remove these.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 const char* name; 78 const char* name;
79 void (*fn)(Fuzz*); 79 void (*fn)(Fuzz*);
80 }; 80 };
81 81
82 #define DEF_FUZZ(name, f) \ 82 #define DEF_FUZZ(name, f) \
83 static void fuzz_##name(Fuzz*); \ 83 static void fuzz_##name(Fuzz*); \
84 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ 84 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \
85 static void fuzz_##name(Fuzz* f) 85 static void fuzz_##name(Fuzz* f)
86 86
87 #endif//Fuzz_DEFINED 87 #endif//Fuzz_DEFINED
OLDNEW
« no previous file with comments | « no previous file | fuzz/FuzzGradients.cpp » ('j') | fuzz/FuzzGradients.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698