test: use malloc/free tests are library consumers, MP_MALLOC is an internal macro
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
diff --git a/demo/test.c b/demo/test.c
index 8cad788..81f5afe 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -2313,7 +2313,7 @@ static int test_mp_read_write_ubin(void)
size = mp_ubin_size(&a);
printf("mp_to_ubin_size %zu\n", size);
- buf = MP_MALLOC(sizeof(*buf) * size);
+ buf = malloc(sizeof(*buf) * size);
if (buf == NULL) {
fprintf(stderr, "test_read_write_binaries (u) failed to allocate %zu bytes\n",
sizeof(*buf) * size);
@@ -2333,9 +2333,7 @@ static int test_mp_read_write_ubin(void)
mp_clear_multi(&a, &b, &c, NULL);
return EXIT_SUCCESS;
LTM_ERR:
- if (buf != NULL) {
- free(buf);
- }
+ free(buf);
mp_clear_multi(&a, &b, &c, NULL);
return EXIT_FAILURE;
}
@@ -2356,7 +2354,7 @@ static int test_mp_read_write_sbin(void)
size = mp_sbin_size(&a);
printf("mp_to_sbin_size %zu\n", size);
- buf = MP_MALLOC(sizeof(*buf) * size);
+ buf = malloc(sizeof(*buf) * size);
if (buf == NULL) {
fprintf(stderr, "test_read_write_binaries (s) failed to allocate %zu bytes\n",
sizeof(*buf) * size);
@@ -2377,9 +2375,7 @@ static int test_mp_read_write_sbin(void)
mp_clear_multi(&a, &b, &c, NULL);
return EXIT_SUCCESS;
LTM_ERR:
- if (buf != NULL) {
- free(buf);
- }
+ free(buf);
mp_clear_multi(&a, &b, &c, NULL);
return EXIT_FAILURE;
}
@@ -2399,7 +2395,7 @@ static int test_mp_pack_unpack(void)
count = mp_pack_count(&a, 0, 1);
- buf = MP_MALLOC(count);
+ buf = malloc(count);
if (buf == NULL) {
fprintf(stderr, "test_pack_unpack failed to allocate\n");
goto LTM_ERR;
@@ -2415,13 +2411,11 @@ static int test_mp_pack_unpack(void)
goto LTM_ERR;
}
- MP_FREE(buf, size);
+ free(buf);
mp_clear_multi(&a, &b, NULL);
return EXIT_SUCCESS;
LTM_ERR:
- if (buf != NULL) {
- MP_FREE(buf, size);
- }
+ free(buf);
mp_clear_multi(&a, &b, NULL);
return EXIT_FAILURE;
}