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

Side by Side Diff: fuzz/Fuzz.h

Issue 2212493002: Convert SkAutoTUnref<SkData> to sk_sp<SkData>. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 months 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 | « fuzz/FilterFuzz.cpp ('k') | gm/image.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
(...skipping 29 matching lines...) Expand all
40 */ 40 */
41 float nextRangeF(float min, float max); 41 float nextRangeF(float min, float max);
42 42
43 void signalBug (); // Tell afl-fuzz these inputs found a bug. 43 void signalBug (); // Tell afl-fuzz these inputs found a bug.
44 void signalBoring(); // Tell afl-fuzz these inputs are not worth testing. 44 void signalBoring(); // Tell afl-fuzz these inputs are not worth testing.
45 45
46 private: 46 private:
47 template <typename T> 47 template <typename T>
48 T nextT(); 48 T nextT();
49 49
50 SkAutoTUnref<SkData> fBytes; 50 sk_sp<SkData> fBytes;
51 int fNextByte; 51 int fNextByte;
52 }; 52 };
53 53
54 template <typename T> 54 template <typename T>
55 bool Fuzz::next(T* n) { 55 bool Fuzz::next(T* n) {
56 if (fNextByte + sizeof(T) > fBytes->size()) { 56 if (fNextByte + sizeof(T) > fBytes->size()) {
57 return false; 57 return false;
58 } 58 }
59 59
60 memcpy(n, fBytes->bytes() + fNextByte, sizeof(T)); 60 memcpy(n, fBytes->bytes() + fNextByte, sizeof(T));
61 fNextByte += sizeof(T); 61 fNextByte += sizeof(T);
62 return true; 62 return true;
63 } 63 }
64 64
65 struct Fuzzable { 65 struct Fuzzable {
66 const char* name; 66 const char* name;
67 void (*fn)(Fuzz*); 67 void (*fn)(Fuzz*);
68 }; 68 };
69 69
70 #define DEF_FUZZ(name, f) \ 70 #define DEF_FUZZ(name, f) \
71 static void fuzz_##name(Fuzz*); \ 71 static void fuzz_##name(Fuzz*); \
72 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \ 72 SkTRegistry<Fuzzable> register_##name({#name, fuzz_##name}); \
73 static void fuzz_##name(Fuzz* f) 73 static void fuzz_##name(Fuzz* f)
74 74
75 #endif//Fuzz_DEFINED 75 #endif//Fuzz_DEFINED
OLDNEW
« no previous file with comments | « fuzz/FilterFuzz.cpp ('k') | gm/image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698