aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/fuzz.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-01-02 19:29:36 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-02-03 19:30:14 +0100
commitfaf7d7418cf01cb04cd457bcc630654da958a777 (patch)
tree7adaeeef624d4921c6895b715197a5dcf47b2ac7 /src/test/fuzz/fuzz.h
parentea96e17e1f2c2b0a949366260906ef02e560a425 (diff)
downloadbitcoin-faf7d7418cf01cb04cd457bcc630654da958a777.tar.xz
fuzz: Avoid extraneous copy of input data, using Span<>
Diffstat (limited to 'src/test/fuzz/fuzz.h')
-rw-r--r--src/test/fuzz/fuzz.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/test/fuzz/fuzz.h b/src/test/fuzz/fuzz.h
index 52841e069a..19386a5059 100644
--- a/src/test/fuzz/fuzz.h
+++ b/src/test/fuzz/fuzz.h
@@ -5,12 +5,15 @@
#ifndef BITCOIN_TEST_FUZZ_FUZZ_H
#define BITCOIN_TEST_FUZZ_FUZZ_H
+#include <span.h>
+
#include <cstdint>
#include <functional>
#include <string_view>
-#include <vector>
-using TypeTestOneInput = std::function<void(const std::vector<uint8_t>&)>;
+using FuzzBufferType = Span<const uint8_t>;
+
+using TypeTestOneInput = std::function<void(FuzzBufferType)>;
using TypeInitialize = std::function<void()>;
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, TypeInitialize init);
@@ -21,13 +24,13 @@ inline void FuzzFrameworkEmptyFun() {}
FUZZ_TARGET_INIT(name, FuzzFrameworkEmptyFun)
#define FUZZ_TARGET_INIT(name, init_fun) \
- void name##_fuzz_target(const std::vector<uint8_t>&); \
+ void name##_fuzz_target(FuzzBufferType); \
struct name##_Before_Main { \
name##_Before_Main() \
{ \
FuzzFrameworkRegisterTarget(#name, name##_fuzz_target, init_fun); \
} \
} const static g_##name##_before_main; \
- void name##_fuzz_target(const std::vector<uint8_t>& buffer)
+ void name##_fuzz_target(FuzzBufferType buffer)
#endif // BITCOIN_TEST_FUZZ_FUZZ_H