From d44dd1c42661fae46cc32f3dd83d05a831018d00 Mon Sep 17 00:00:00 2001 From: Jiuzhu Dong Date: Sat, 16 Apr 2022 18:24:02 +0800 Subject: [PATCH] uorb_unit_test: optimize stack used Signed-off-by: Jiuzhu Dong --- system/uorb/test/unit_test.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/system/uorb/test/unit_test.c b/system/uorb/test/unit_test.c index 0aaa0a1b7..2ae6f88a3 100644 --- a/system/uorb/test/unit_test.c +++ b/system/uorb/test/unit_test.c @@ -61,11 +61,17 @@ static int pubsubtest_thread_entry(int argc, FAR char *argv[]) int current_value; int num_missed = 0; unsigned timingsgroup = 0; - unsigned timings[MAX_RUNS]; + FAR unsigned *timings; unsigned timing_min = 9999999; unsigned timing_max = 0; unsigned i; + timings = malloc(MAX_RUNS * sizeof(unsigned)); + if (timings == NULL) + { + return -ENOMEM; + } + /* clear all ready flags */ test_multi_sub = orb_subscribe_multi(ORB_ID(orb_test_medium), 0); @@ -128,6 +134,7 @@ static int pubsubtest_thread_entry(int argc, FAR char *argv[]) if (f == NULL) { snerr("Error opening file!"); + free(timings); return ERROR; } @@ -167,6 +174,7 @@ static int pubsubtest_thread_entry(int argc, FAR char *argv[]) g_pubsubtest_res = OK; } + free(timings); return g_pubsubtest_res; }