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

Side by Side Diff: fuzz/Fuzz.h

Issue 2446643003: Fix memory leak in FuzzGradients (Closed)
Patch Set: include vector 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') | no next file with comments »
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 #include <vector>
16
15 class Fuzz : SkNoncopyable { 17 class Fuzz : SkNoncopyable {
16 public: 18 public:
17 explicit Fuzz(sk_sp<SkData>); 19 explicit Fuzz(sk_sp<SkData>);
18 20
19 // Returns the total number of "random" bytes available. 21 // Returns the total number of "random" bytes available.
20 size_t size(); 22 size_t size();
21 // Returns the total number of "random" bytes remaining for randomness. 23 // Returns the total number of "random" bytes remaining for randomness.
22 size_t remaining(); 24 size_t remaining();
23 25
24 template <typename T> 26 template <typename T>
25 bool next(T* n); 27 bool SK_WARN_UNUSED_RESULT next(T* n);
26 28
27 // UBSAN reminds us that bool can only legally hold 0 or 1. 29 // UBSAN reminds us that bool can only legally hold 0 or 1.
28 bool next(bool* b) { 30 bool SK_WARN_UNUSED_RESULT next(bool* b) {
29 uint8_t byte; 31 uint8_t byte;
30 if (!this->next(&byte)) { 32 if (!this->next(&byte)) {
31 return false; 33 return false;
32 } 34 }
33 *b = (byte & 1) == 1; 35 *b = (byte & 1) == 1;
34 return true; 36 return true;
35 } 37 }
36 38
37 // The nextFoo methods are deprecated. 39 // The nextFoo methods are deprecated.
38 // TODO(kjlubick): replace existing uses with next() and remove these. 40 // 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; 80 const char* name;
79 void (*fn)(Fuzz*); 81 void (*fn)(Fuzz*);
80 }; 82 };
81 83
82 #define DEF_FUZZ(name, f) \ 84 #define DEF_FUZZ(name, f) \
83 static void fuzz_##name(Fuzz*); \ 85 static void fuzz_##name(Fuzz*); \
84 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ 86 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \
85 static void fuzz_##name(Fuzz* f) 87 static void fuzz_##name(Fuzz* f)
86 88
87 #endif//Fuzz_DEFINED 89 #endif//Fuzz_DEFINED
OLDNEW
« no previous file with comments | « no previous file | fuzz/FuzzGradients.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698