mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-01-13 09:42:05 +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) \
|
#define PRINT_POINTER(caption, ptr) \
|
||||||
printf(caption " = %p\n", (void*) 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); \
|
printf("%s: [", caption); \
|
||||||
for (size_t i = 0; i < count; i++) { \
|
for (size_t i = 0; i < count; i++) { \
|
||||||
printf("%d", ptr[i]); \
|
printf(fmt, ptr[i]); \
|
||||||
if (i != (count - 1)) \
|
if (i != (count - 1)) \
|
||||||
printf(", "); \
|
printf(", "); \
|
||||||
} \
|
} \
|
||||||
@ -37,7 +37,8 @@ int main(void) {
|
|||||||
integers[1] = EOF;
|
integers[1] = EOF;
|
||||||
integers[2] = 2;
|
integers[2] = 2;
|
||||||
integers[3] = 1;
|
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 "
|
printf("Secure erasure is "
|
||||||
#if NO_SECURE_ERASE_WARRANTY
|
#if NO_SECURE_ERASE_WARRANTY
|
||||||
"not guaranteed!"
|
"not guaranteed!"
|
||||||
@ -51,7 +52,8 @@ int main(void) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
secure_erase(integers, COUNT * sizeof(int));
|
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);
|
safe_free(integers);
|
||||||
PRINT_POINTER("int* integers (after freeing)", integers);
|
PRINT_POINTER("int* integers (after freeing)", integers);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user