Revision aa211c2d5a40dd6969fe8a469fcadfd27e8c8fe3 authored by Jonathan Protzenko on 24 April 2020, 21:11:09 UTC, committed by Jonathan Protzenko on 24 April 2020, 21:11:09 UTC
1 parent 6f91754
Lib_Memzero.c
#include <stdint.h>
void clear_words(void* mem, unsigned int nwords)
{ // Clear 32-bit words from memory. "nwords" indicates the number of words to be zeroed.
// This function uses the volatile type qualifier to inform the compiler not to optimize out the memory clearing.
volatile uint32_t *v = mem;
for (unsigned int i = 0; i < nwords; i++) {
v[i] = (uint32_t)0U;
}
}
void Lib_Memzero_clear_words_u16(unsigned int nwords, uint16_t *mem)
{
clear_words((void*)mem, nwords/2);
}
void Lib_Memzero_clear_words_u8(unsigned int nwords, uint8_t *mem)
{
clear_words((void*)mem, nwords/4);
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...