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

Unified Diff: fuzz/Fuzz.h

Issue 2148023002: Port FuzzPathop from chromium (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | fuzz/FuzzPathop.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fuzz/Fuzz.h
diff --git a/fuzz/Fuzz.h b/fuzz/Fuzz.h
index 07c2c8456e248cc35ec7f65d1dd8f19f64d007ab..79bf675f45ae15dde6121191ca53bb0694b9c941 100644
--- a/fuzz/Fuzz.h
+++ b/fuzz/Fuzz.h
@@ -16,6 +16,14 @@ class Fuzz : SkNoncopyable {
public:
explicit Fuzz(SkData*);
+ // Returns the total number of "random" bytes available.
+ size_t size();
+ // Returns the total number of "random" bytes remaining for randomness.
+ size_t remaining();
+
+ template <typename T>
+ bool next(T* n);
+
bool nextBool();
uint8_t nextB();
uint32_t nextU();
@@ -43,6 +51,17 @@ private:
int fNextByte;
};
+template <typename T>
+bool Fuzz::next(T* n) {
+ if (fNextByte + sizeof(T) > fBytes->size()) {
+ return false;
+ }
+
+ memcpy(n, fBytes->bytes() + fNextByte, sizeof(T));
+ fNextByte += sizeof(T);
+ return true;
+}
+
struct Fuzzable {
const char* name;
void (*fn)(Fuzz*);
« no previous file with comments | « no previous file | fuzz/FuzzPathop.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698