1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-10-31 18:04:37 +00:00
CLK/Machines/Utility/MemoryFuzzer.hpp

32 lines
728 B
C++
Raw Normal View History

//
// MemoryFuzzer.hpp
// Clock Signal
//
// Created by Thomas Harte on 19/10/2016.
// Copyright 2016 Thomas Harte. All rights reserved.
//
#ifndef MemoryFuzzer_hpp
#define MemoryFuzzer_hpp
#include <cstdint>
#include <cstddef>
#include <vector>
namespace Memory {
2017-07-22 21:39:51 +00:00
/// Stores @c size random bytes from @c buffer onwards.
void Fuzz(uint8_t *buffer, std::size_t size);
2017-07-22 21:39:51 +00:00
/// Stores @c size random 16-bit words from @c buffer onwards.
void Fuzz(uint16_t *buffer, std::size_t size);
/// Replaces all existing vector contents with random bytes.
2019-08-12 01:41:12 +00:00
template <typename T> void Fuzz(std::vector<T> &buffer) {
Fuzz(reinterpret_cast<uint8_t *>(buffer.data()), buffer.size() * sizeof(buffer[0]));
}
}
#endif /* MemoryFuzzer_hpp */