fixed memory leak in custom wave

git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/personal/carm/dev-1.0@296 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
w1z7ard
2007-08-07 01:47:58 +00:00
parent 02724976b7
commit 53a470df10
2 changed files with 4 additions and 12 deletions

View File

@ -79,7 +79,6 @@ CustomWave::CustomWave(int _id):
this->value2 = (float*)wipemalloc(MAX_SAMPLE_SIZE*sizeof(float));
this->sample_mesh = (float*)wipemalloc(MAX_SAMPLE_SIZE*sizeof(float));
/* Start: Load custom wave parameters */
if ((param = Param::new_param_float("r", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &this->r, this->r_mesh, 1.0, 0.0, .5)) == NULL) {
@ -93,11 +92,10 @@ CustomWave::CustomWave(int _id):
abort();
}
if ((param = Param::new_param_float("g", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &this->g, this->g_mesh, 1.0, 0.0, .5)) == NULL){
if ((param = Param::new_param_float("g", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &this->g, this->g_mesh, 1.0, 0.0, .5)) == NULL) {
delete(this);
/// @bug make exception
abort();
}
if (ParamUtils::insert(param, param_tree) < 0) {
@ -117,37 +115,30 @@ CustomWave::CustomWave(int _id):
delete(this);
/// @bug make exception
abort();
}
if ((param = Param::new_param_float("a", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &this->a, this->a_mesh, 1.0, 0.0, .5)) == NULL){
delete(this);
/// @bug make exception
abort();
}
if (ParamUtils::insert(param, this->param_tree) < 0) {
delete(this);
/// @bug make exception
abort();
}
if ((param = Param::new_param_float("x", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &this->x, this->x_mesh, 1.0, 0.0, .5)) == NULL) {
delete(this);
/// @bug make exception
abort();
}
if (ParamUtils::insert(param, this->param_tree) < 0) {
delete(this);
/// @bug make exception
abort();
}
if ((param = Param::new_param_float("y", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &this->y, this->y_mesh, 1.0, 0.0, .5)) == NULL) {
@ -413,6 +404,8 @@ CustomWave::~CustomWave() {
delete(pos->second);
delete(param_tree);
free(r_mesh);
free(g_mesh);
free(b_mesh);

View File

@ -212,7 +212,6 @@ inline Preset * PresetChooser::doWeightedSample(WeightFunctor & weightFunctor, c
// Choose a random bounded mass between 0 and 1
float cutoff = ((float)(random())) / RAND_MAX;
std::cerr << "cutoff: " << cutoff << std::endl;
// Sum up mass, stopping when cutoff is reached. This is the typical
// weighted sampling algorithm.
float mass = 0;
@ -225,7 +224,7 @@ inline Preset * PresetChooser::doWeightedSample(WeightFunctor & weightFunctor, c
// Just in case something slips through the cracks
PresetIterator pos = this->end();
--pos;
std::cerr << "mass: " << mass << std::endl;
return pos.allocate(presetInputs, presetOutputs);
}