2016-10-19 21:31:50 -04:00
|
|
|
//
|
|
|
|
// MemoryFuzzer.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 19/10/2016.
|
2018-05-13 15:19:52 -04:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-10-19 21:31:50 -04:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef MemoryFuzzer_hpp
|
|
|
|
#define MemoryFuzzer_hpp
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstddef>
|
2017-06-05 10:36:07 -04:00
|
|
|
#include <vector>
|
2016-10-19 21:31:50 -04:00
|
|
|
|
|
|
|
namespace Memory {
|
|
|
|
|
2017-07-22 17:39:51 -04:00
|
|
|
/// Stores @c size random bytes from @c buffer onwards.
|
2017-11-11 15:28:40 -05:00
|
|
|
void Fuzz(uint8_t *buffer, std::size_t size);
|
2017-07-22 17:39:51 -04:00
|
|
|
|
2019-06-13 13:35:16 -04:00
|
|
|
/// Stores @c size random 16-bit words from @c buffer onwards.
|
|
|
|
void Fuzz(uint16_t *buffer, std::size_t size);
|
|
|
|
|
2021-02-12 21:50:24 -05:00
|
|
|
/// Replaces all existing vector or array contents with random bytes.
|
|
|
|
template <typename T> void Fuzz(T &buffer) {
|
|
|
|
Fuzz(reinterpret_cast<uint8_t *>(buffer.data()), buffer.size() * sizeof(typename T::value_type));
|
2019-08-11 21:41:12 -04:00
|
|
|
}
|
2016-10-19 21:31:50 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MemoryFuzzer_hpp */
|