aboutsummaryrefslogtreecommitdiff
path: root/src/memory.cpp
blob: 07e8de2f7524e38e507d63ba2a5513840c7a8e8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "axolotl/memory.hh"


void axolotl::unset(
    void volatile * buffer, std::size_t buffer_length
) {
    char volatile * pos = reinterpret_cast<char volatile *>(buffer);
    char volatile * end = pos + buffer_length;
    while (pos != end) {
        *(pos++) = 0;
    }
}


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;
}