edits
authorbdemsky <bdemsky@uci.edu>
Sat, 20 Jan 2018 07:20:07 +0000 (23:20 -0800)
committerbdemsky <bdemsky@uci.edu>
Sat, 20 Jan 2018 07:20:07 +0000 (23:20 -0800)
version2/src/C/SlotBuffer.cc
version2/src/C/SlotBuffer.h

index de4bbe0bc64a43f14851d46b2eb401dbeacbc409..248abd78017f03237e0f74cd8cf5bfc8403ad962 100644 (file)
@@ -13,6 +13,10 @@ SlotBuffer::SlotBuffer() :
        oldestseqn(0) {
 }
 
        oldestseqn(0) {
 }
 
+SlotBuffer::~SlotBuffer() {
+       delete array;
+}
+
 int SlotBuffer::size() {
        if (head >= tail)
                return head - tail;
 int SlotBuffer::size() {
        if (head >= tail)
                return head - tail;
@@ -56,7 +60,6 @@ void SlotBuffer::putSlot(Slot *s) {
        int64_t checkNum = (getNewestSeqNum() + 1);
 
        if (checkNum != s->getSequenceNumber()) {
        int64_t checkNum = (getNewestSeqNum() + 1);
 
        if (checkNum != s->getSequenceNumber()) {
-               // We have a gap so expunge all our slots
                oldestseqn = s->getSequenceNumber();
                tail = 0;
                head = 1;
                oldestseqn = s->getSequenceNumber();
                tail = 0;
                head = 1;
@@ -82,7 +85,6 @@ Slot *SlotBuffer::getSlot(int64_t seqnum) {
        int32_t index = diff + tail;
 
        if (index < 0) {
        int32_t index = diff + tail;
 
        if (index < 0) {
-               // Really old message so we dont have it anymore
                return NULL;
        }
 
                return NULL;
        }
 
@@ -94,9 +96,9 @@ Slot *SlotBuffer::getSlot(int64_t seqnum) {
        }
 
        if (index >= array->length()) {
        }
 
        if (index >= array->length()) {
-
                return NULL;
        }
                return NULL;
        }
+
        if (head >= tail && index >= head) {
                return NULL;
        }
        if (head >= tail && index >= head) {
                return NULL;
        }
index 7027de67a66616ff08dc52e222619b19450d5dba..4122cd1745114011c188511a8da88dbc877e255f 100644 (file)
@@ -16,13 +16,13 @@ private:
        Array<Slot *> *array;
        int32_t head;
        int32_t tail;
        Array<Slot *> *array;
        int32_t head;
        int32_t tail;
+       int64_t oldestseqn;
        void incrementHead();
        void incrementTail();
 
 public:
        void incrementHead();
        void incrementTail();
 
 public:
-       int64_t oldestseqn;
-
        SlotBuffer();
        SlotBuffer();
+       ~SlotBuffer();
        int32_t size();
        int32_t capacity();
        void resize(int newsize);
        int32_t size();
        int32_t capacity();
        void resize(int newsize);