Skip to content
Snippets Groups Projects
Commit cfe4ed54 authored by Andrei Herdt's avatar Andrei Herdt Committed by Olivier Stasse
Browse files

Add exception handling to the reallocation

parent 13819817
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,8 @@
#include <iostream>
#include <fstream>
#include <exception>
#include <ZMPRefTrajectoryGeneration/qp-problem.hh>
using namespace PatternGeneratorJRL;
......@@ -113,21 +115,41 @@ void QPProblem_s::AllocateMemory()
}
void
int
QPProblem_s::resize(double * array, int size)
{
if (array!=0)
delete [] array;
array = new double[size];
try
{
array = new double[size];
}
catch (std::bad_alloc& ba)
{
std::cerr << "bad_alloc caught: " << ba.what() << std::endl;
}
return 0;
}
void
int
QPProblem_s::resize(int * array, int size)
{
if (array!=0)
delete [] array;
array = new int[size];
try
{
array = new int[size];
}
catch (std::bad_alloc& ba)
{
std::cerr << "bad_alloc caught: " << ba.what() << std::endl;
}
return 0;
}
......
......@@ -64,8 +64,8 @@ namespace PatternGeneratorJRL
int QP_N);
/// \brief Reallocate array
void resize(double * array, int size);
void resize(int * array, int size);
int resize(double * array, int size);
int resize(int * array, int size);
/// \brief Dump on disk a problem.
void dumpProblem(const char *filename);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment