edits
[iotcloud.git] / version2 / src / C / SlotBuffer.cc
index aa217ac17dda116f1ca2c48c3d498a93d182ae9d..06c46e901d8f60a5970025476480c29da18d7e66 100644 (file)
@@ -14,6 +14,13 @@ SlotBuffer::SlotBuffer() :
 }
 
 SlotBuffer::~SlotBuffer() {
+       int32_t index = tail;
+       while (index != head) {
+               delete array->get(index);
+               index++;
+               if (index == (int32_t) 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()) {
+               int32_t index = tail;
+               while (index != head) {
+                       delete array->get(index);
+                       index++;
+                       if (index == (int32_t) array->length())
+                               index = 0;
+               }
                oldestseqn = s->getSequenceNumber();
                tail = 0;
                head = 1;