Skip to content

Commit c7b4c7a

Browse files
Merge pull request #5379 from maciejbocianski/race_mem_fix
race test: fix out of memory problem for NUCLEO_F070RB
2 parents bfcb173 + 9bf936c commit c7b4c7a

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

TESTS/mbed_drivers/race_test/main.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,18 @@ static void main_class_race()
6868
void test_case_func_race()
6969
{
7070
Callback<void()> cb(main_func_race);
71-
Thread *t1 = new Thread(osPriorityNormal, TEST_STACK_SIZE);
72-
Thread *t2 = new Thread(osPriorityNormal, TEST_STACK_SIZE);
71+
Thread t1(osPriorityNormal, TEST_STACK_SIZE);
72+
Thread t2(osPriorityNormal, TEST_STACK_SIZE);
7373

7474
// Start start first thread
75-
t1->start(cb);
75+
t1.start(cb);
7676
// Start second thread while the first is inside the constructor
7777
Thread::wait(250);
78-
t2->start(cb);
78+
t2.start(cb);
7979

8080
// Wait for the threads to finish
81-
t1->join();
82-
t2->join();
83-
84-
delete t1;
85-
delete t2;
81+
t1.join();
82+
t2.join();
8683

8784
TEST_ASSERT_EQUAL_UINT32(1, instance_count);
8885

@@ -93,21 +90,18 @@ void test_case_func_race()
9390
void test_case_class_race()
9491
{
9592
Callback<void()> cb(main_class_race);
96-
Thread *t1 = new Thread(osPriorityNormal, TEST_STACK_SIZE);
97-
Thread *t2 = new Thread(osPriorityNormal, TEST_STACK_SIZE);
93+
Thread t1(osPriorityNormal, TEST_STACK_SIZE);
94+
Thread t2(osPriorityNormal, TEST_STACK_SIZE);
9895

9996
// Start start first thread
100-
t1->start(cb);
97+
t1.start(cb);
10198
// Start second thread while the first is inside the constructor
10299
Thread::wait(250);
103-
t2->start(cb);
100+
t2.start(cb);
104101

105102
// Wait for the threads to finish
106-
t1->join();
107-
t2->join();
108-
109-
delete t1;
110-
delete t2;
103+
t1.join();
104+
t2.join();
111105

112106
TEST_ASSERT_EQUAL_UINT32(1, instance_count);
113107

0 commit comments

Comments
 (0)