2015-02-27 17:11:30 +01:00
|
|
|
#include "axolotl/memory.hh"
|
|
|
|
|
2015-03-03 16:08:56 +01:00
|
|
|
|
2015-02-27 17:11:30 +01:00
|
|
|
void axolotl::unset(
|
2015-03-03 16:08:56 +01:00
|
|
|
void volatile * buffer, std::size_t buffer_length
|
2015-02-27 17:11:30 +01:00
|
|
|
) {
|
2015-03-03 16:08:56 +01:00
|
|
|
char volatile * pos = reinterpret_cast<char volatile *>(buffer);
|
|
|
|
char volatile * end = pos + buffer_length;
|
2015-02-27 17:11:30 +01:00
|
|
|
while (pos != end) {
|
|
|
|
*(pos++) = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-03-03 16:08:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
bool axolotl::is_equal(
|
|
|
|
std::uint8_t const * buffer_a,
|
|
|
|
std::uint8_t const * buffer_b,
|
|
|
|
std::size_t length
|
|
|
|
) {
|
|
|
|
std::uint8_t volatile result = 0;
|
|
|
|
while (length--) {
|
|
|
|
result |= (*(buffer_a++)) ^ (*(buffer_b++));
|
|
|
|
}
|
|
|
|
return result == 0;
|
|
|
|
}
|