Modernize manual memzero implementation
Instead of using volatile pointers to prevent the compiler from optimizing the call away, use a memory barrier. This requires support for embedded assembly, which should be fine after the recent requirement bumps.
This commit is contained in:
parent
90ead3cfb8
commit
e0d79ee032
@ -54,10 +54,8 @@
|
||||
#else /* !HAVE_MEMSET_S && HAVE_EXPLICIT_BZERO */
|
||||
static inline void memzero(void *ptr, size_t size)
|
||||
{
|
||||
volatile unsigned char * volatile p = ptr;
|
||||
while (size--) {
|
||||
*p++ = '\0';
|
||||
}
|
||||
ptr = memset(ptr, '\0', size);
|
||||
__asm__ __volatile__ ("" : : "r"(ptr) : "memory");
|
||||
}
|
||||
#endif /* !HAVE_MEMSET_S && !HAVE_EXPLICIT_BZERO */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user