mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-13 02:17:46 +00:00
tpm2: Introduce clear_and_free() to clear memory before freeing
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
1ae430e708
commit
f5e4768265
@ -39,7 +39,16 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include "Memory_fp.h"
|
||||
|
||||
#define TPM2_ROUNDUP(VAL, SIZE) \
|
||||
( ( (VAL) + (SIZE) - 1) / (SIZE) ) * (SIZE)
|
||||
|
||||
static inline void clear_and_free(void *ptr, size_t size) {
|
||||
if (ptr) {
|
||||
MemorySet(ptr, 0, size);
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* UTILS_H */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user