fix a leak in StdDev

This commit is contained in:
Stephen Birarda 2014-11-07 17:11:00 -08:00
parent c04e653cf3
commit 4fd22914c0
2 changed files with 9 additions and 6 deletions

View file

@ -13,14 +13,15 @@
#include <cmath> #include <cmath>
#include "StdDev.h" #include "StdDev.h"
const int NUM_SAMPLES = 1000; StDev::StDev() :
_data(),
StDev::StDev() { _sampleCount(0)
_data = new float[NUM_SAMPLES]; {
_sampleCount = 0; reset();
} }
void StDev::reset() { void StDev::reset() {
memset(&_data, 0, sizeof(_data));
_sampleCount = 0; _sampleCount = 0;
} }

View file

@ -12,6 +12,8 @@
#ifndef hifi_StdDev_h #ifndef hifi_StdDev_h
#define hifi_StdDev_h #define hifi_StdDev_h
const int NUM_SAMPLES = 1000;
class StDev { class StDev {
public: public:
StDev(); StDev();
@ -21,7 +23,7 @@ public:
float getStDev() const; float getStDev() const;
int getSamples() const { return _sampleCount; } int getSamples() const { return _sampleCount; }
private: private:
float* _data; float _data[NUM_SAMPLES];
int _sampleCount; int _sampleCount;
}; };