diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 2c78257d2b..e00d8eb44d 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include "AudioRingBuffer.h" diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 3039b7adfb..4a488bb296 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/interface/src/Audio.h b/interface/src/Audio.h index bec2ce32a0..6de7cf8d91 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -40,12 +40,12 @@ #include #include -#include +#include #include "MixedProcessedAudioStream.h" #include "AudioEffectOptions.h" #include -#include +#include extern "C" { #include diff --git a/interface/src/Hair.cpp b/interface/src/Hair.cpp index 637e00a8bc..119f5a31d0 100644 --- a/interface/src/Hair.cpp +++ b/interface/src/Hair.cpp @@ -90,6 +90,17 @@ Hair::Hair(int strands, } } +Hair::~Hair() { + delete[] _hairPosition; + delete[] _hairOriginalPosition; + delete[] _hairLastPosition; + delete[] _hairQuadDelta; + delete[] _hairNormals; + delete[] _hairColors; + delete[] _hairIsMoveable; + delete[] _hairConstraints; +} + const float SOUND_THRESHOLD = 40.0f; void Hair::simulate(float deltaTime) { diff --git a/interface/src/Hair.h b/interface/src/Hair.h index 05c82e66f7..436c6b836a 100644 --- a/interface/src/Hair.h +++ b/interface/src/Hair.h @@ -37,6 +37,7 @@ public: float radius = DEFAULT_HAIR_RADIUS, float linkLength = DEFAULT_HAIR_LINK_LENGTH, float hairThickness = DEFAULT_HAIR_THICKNESS); + ~Hair(); void simulate(float deltaTime); void render(); void setAcceleration(const glm::vec3& acceleration) { _acceleration = acceleration; } diff --git a/libraries/audio/src/InboundAudioStream.h b/libraries/audio/src/InboundAudioStream.h index a9ebc70072..4621de2899 100644 --- a/libraries/audio/src/InboundAudioStream.h +++ b/libraries/audio/src/InboundAudioStream.h @@ -18,7 +18,7 @@ #include "SequenceNumberStats.h" #include "AudioStreamStats.h" #include "PacketHeaders.h" -#include "StdDev.h" +#include "StDev.h" #include "TimeWeightedAvg.h" // This adds some number of frames to the desired jitter buffer frames target we use when we're dropping frames. diff --git a/libraries/octree/src/OctreeElement.cpp b/libraries/octree/src/OctreeElement.cpp index 271e885d17..a0a331beb3 100644 --- a/libraries/octree/src/OctreeElement.cpp +++ b/libraries/octree/src/OctreeElement.cpp @@ -68,7 +68,8 @@ void OctreeElement::init(unsigned char * octalCode) { // set up the _children union _childBitmask = 0; _childrenExternal = false; - + + #ifdef BLENDED_UNION_CHILDREN _children.external = NULL; _singleChildrenCount++; @@ -660,6 +661,11 @@ void OctreeElement::deleteAllChildren() { delete childAt; } } + + if (_childrenExternal) { + // if the children_t union represents _children.external we need to delete it here + delete[] _children.external; + } #ifdef BLENDED_UNION_CHILDREN // now, reset our internal state and ANY and all population data @@ -757,6 +763,8 @@ void OctreeElement::setChildAtIndex(int childIndex, OctreeElement* child) { memset(_children.external, 0, sizeof(OctreeElement*) * NUMBER_OF_CHILDREN); _children.external[firstIndex] = previousChild; _children.external[childIndex] = child; + + _childrenExternal = true; _externalChildrenMemoryUsage += NUMBER_OF_CHILDREN * sizeof(OctreeElement*); @@ -764,7 +772,10 @@ void OctreeElement::setChildAtIndex(int childIndex, OctreeElement* child) { assert(!child); // we are removing a child, so this must be true! OctreeElement* previousFirstChild = _children.external[firstIndex]; OctreeElement* previousSecondChild = _children.external[secondIndex]; + delete[] _children.external; + _childrenExternal = false; + _externalChildrenMemoryUsage -= NUMBER_OF_CHILDREN * sizeof(OctreeElement*); if (childIndex == firstIndex) { _children.single = previousSecondChild; diff --git a/libraries/shared/src/StdDev.cpp b/libraries/shared/src/StDev.cpp similarity index 87% rename from libraries/shared/src/StdDev.cpp rename to libraries/shared/src/StDev.cpp index 387b67cf4f..23afd12b98 100644 --- a/libraries/shared/src/StdDev.cpp +++ b/libraries/shared/src/StDev.cpp @@ -1,5 +1,5 @@ // -// StdDev.cpp +// StDev.cpp // libraries/shared/src // // Created by Philip Rosedale on 3/12/13. @@ -11,16 +11,18 @@ #include #include -#include "StdDev.h" +#include -const int NUM_SAMPLES = 1000; +#include "StDev.h" -StDev::StDev() { - _data = new float[NUM_SAMPLES]; - _sampleCount = 0; +StDev::StDev() : + _sampleCount(0) +{ + reset(); } void StDev::reset() { + memset(&_data, 0, sizeof(_data)); _sampleCount = 0; } diff --git a/libraries/shared/src/StdDev.h b/libraries/shared/src/StDev.h similarity index 78% rename from libraries/shared/src/StdDev.h rename to libraries/shared/src/StDev.h index 40148007a9..ab48aae6b5 100644 --- a/libraries/shared/src/StdDev.h +++ b/libraries/shared/src/StDev.h @@ -1,5 +1,5 @@ // -// StdDev.h +// StDev.h // libraries/shared/src // // Created by Philip Rosedale on 3/12/13. @@ -9,8 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_StdDev_h -#define hifi_StdDev_h +#ifndef hifi_StDev_h +#define hifi_StDev_h + +const int NUM_SAMPLES = 1000; class StDev { public: @@ -21,8 +23,8 @@ public: float getStDev() const; int getSamples() const { return _sampleCount; } private: - float* _data; + float _data[NUM_SAMPLES]; int _sampleCount; }; -#endif // hifi_StdDev_h +#endif // hifi_StDev_h diff --git a/tests/jitter/src/main.cpp b/tests/jitter/src/main.cpp index 985ce99530..baaa2d08d6 100644 --- a/tests/jitter/src/main.cpp +++ b/tests/jitter/src/main.cpp @@ -20,7 +20,7 @@ #include #include // for usecTimestampNow #include -#include +#include const quint64 MSEC_TO_USEC = 1000; const quint64 LARGE_STATS_TIME = 500; // we don't expect stats calculation to take more than this many usecs