Fix memory leaks identified by cppcheck

* Add `free` / `delete`
* Add comment explaining the (presumed) motivation for the use of new instead of
  allocating on the stack
This commit is contained in:
Peter Duerr
2017-08-07 15:35:21 +02:00
committed by Lorenz Meier
parent 5be23060e7
commit cc1b766824
2 changed files with 4 additions and 0 deletions
@@ -89,6 +89,7 @@ int uORBTest::UnitTest::pubsublatency_main()
const unsigned maxruns = 1000;
unsigned timingsgroup = 0;
// timings has to be on the heap to keep frame size below 2048 bytes
unsigned *timings = new unsigned[maxruns];
for (unsigned i = 0; i < maxruns; i++) {
@@ -129,6 +130,7 @@ int uORBTest::UnitTest::pubsublatency_main()
if (f == nullptr) {
warnx("Error opening file!\n");
delete[] timings;
return uORB::ERROR;
}