mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-11-09 21:32:02 +05:30
safe_mem.test.c: enhance macro DUMP_INT_ARRAY
for multiple scenarios
This commit is contained in:
parent
f14e505673
commit
269c1dec27
@ -18,10 +18,10 @@
|
||||
|
||||
#define PRINT_POINTER(caption, ptr) \
|
||||
printf(caption " = %p\n", (void*) ptr);
|
||||
#define DUMP_INT_ARRAY(caption, ptr, count) do { \
|
||||
#define DUMP_INT_ARRAY(caption, ptr, count, fmt) do { \
|
||||
printf("%s: [", caption); \
|
||||
for (size_t i = 0; i < count; i++) { \
|
||||
printf("%d", ptr[i]); \
|
||||
printf(fmt, ptr[i]); \
|
||||
if (i != (count - 1)) \
|
||||
printf(", "); \
|
||||
} \
|
||||
@ -37,7 +37,8 @@ int main(void) {
|
||||
integers[1] = EOF;
|
||||
integers[2] = 2;
|
||||
integers[3] = 1;
|
||||
DUMP_INT_ARRAY("int* integers (before secure erasure)", integers, COUNT);
|
||||
DUMP_INT_ARRAY("int* integers (before secure erasure)", integers, COUNT,
|
||||
"%d");
|
||||
printf("Secure erasure is "
|
||||
#if NO_SECURE_ERASE_WARRANTY
|
||||
"not guaranteed!"
|
||||
@ -51,7 +52,8 @@ int main(void) {
|
||||
);
|
||||
|
||||
secure_erase(integers, COUNT * sizeof(int));
|
||||
DUMP_INT_ARRAY("int* integers (after secure erasure)", integers, COUNT);
|
||||
DUMP_INT_ARRAY("int* integers (after secure erasure)", integers, COUNT,
|
||||
"%d");
|
||||
|
||||
safe_free(integers);
|
||||
PRINT_POINTER("int* integers (after freeing)", integers);
|
||||
|
Loading…
Reference in New Issue
Block a user