mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 01:31:42 +00:00
28 lines
484 B
C++
28 lines
484 B
C++
|
//
|
||
|
// MemoryFuzzer.cpp
|
||
|
// Clock Signal
|
||
|
//
|
||
|
// Created by Thomas Harte on 19/10/2016.
|
||
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#include "MemoryFuzzer.hpp"
|
||
|
|
||
|
#include <cstdlib>
|
||
|
|
||
|
void Memory::Fuzz(uint8_t *buffer, size_t size)
|
||
|
{
|
||
|
unsigned int divider = ((unsigned int)RAND_MAX + 1) / 256;
|
||
|
unsigned int shift = 1, value = 1;
|
||
|
while(value < divider)
|
||
|
{
|
||
|
value <<= 1;
|
||
|
shift++;
|
||
|
}
|
||
|
|
||
|
for(size_t c = 0; c < size; c++)
|
||
|
{
|
||
|
buffer[c] = (uint8_t)(rand() >> shift);
|
||
|
}
|
||
|
}
|