edits
[iotcloud.git] / version2 / src / C / SlotBuffer.cc
index aa217ac17dda116f1ca2c48c3d498a93d182ae9d..af6b031ba36b911e6e24a359875ef32c3a0fc649 100644 (file)
@@ -14,6 +14,13 @@ SlotBuffer::SlotBuffer() :
 }
 
 SlotBuffer::~SlotBuffer() {
+       uint index = tail;
+       while (index != head) {
+               delete array->get(index);
+               index++;
+               if (index == array->length())
+                       index = 0;
+       }
        delete array;
 }
 
@@ -51,6 +58,7 @@ void SlotBuffer::incrementHead() {
 }
 
 void SlotBuffer::incrementTail() {
+       delete array->get(tail);
        tail++;
        if (((uint32_t)tail) >= array->length())
                tail = 0;
@@ -60,6 +68,13 @@ void SlotBuffer::putSlot(Slot *s) {
        int64_t checkNum = (getNewestSeqNum() + 1);
 
        if (checkNum != s->getSequenceNumber()) {
+               uint index = tail;
+               while (index != head) {
+                       delete array->get(index);
+                       index++;
+                       if (index == array->length())
+                               index = 0;
+               }
                oldestseqn = s->getSequenceNumber();
                tail = 0;
                head = 1;