uorb_unit_test: optimize stack used

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2022-04-16 18:24:02 +08:00 committed by Alan Carvalho de Assis
parent 6fceb913a2
commit d44dd1c426

View File

@ -61,11 +61,17 @@ static int pubsubtest_thread_entry(int argc, FAR char *argv[])
int current_value; int current_value;
int num_missed = 0; int num_missed = 0;
unsigned timingsgroup = 0; unsigned timingsgroup = 0;
unsigned timings[MAX_RUNS]; FAR unsigned *timings;
unsigned timing_min = 9999999; unsigned timing_min = 9999999;
unsigned timing_max = 0; unsigned timing_max = 0;
unsigned i; unsigned i;
timings = malloc(MAX_RUNS * sizeof(unsigned));
if (timings == NULL)
{
return -ENOMEM;
}
/* clear all ready flags */ /* clear all ready flags */
test_multi_sub = orb_subscribe_multi(ORB_ID(orb_test_medium), 0); 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) if (f == NULL)
{ {
snerr("Error opening file!"); snerr("Error opening file!");
free(timings);
return ERROR; return ERROR;
} }
@ -167,6 +174,7 @@ static int pubsubtest_thread_entry(int argc, FAR char *argv[])
g_pubsubtest_res = OK; g_pubsubtest_res = OK;
} }
free(timings);
return g_pubsubtest_res; return g_pubsubtest_res;
} }