From 816ad1a5d417a8710281974df64ab97e3369360f Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 19 Jan 2018 23:20:07 -0800 Subject: [PATCH 1/1] edits --- version2/src/C/SlotBuffer.cc | 8 +++++--- version2/src/C/SlotBuffer.h | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/version2/src/C/SlotBuffer.cc b/version2/src/C/SlotBuffer.cc index de4bbe0..248abd7 100644 --- a/version2/src/C/SlotBuffer.cc +++ b/version2/src/C/SlotBuffer.cc @@ -13,6 +13,10 @@ SlotBuffer::SlotBuffer() : oldestseqn(0) { } +SlotBuffer::~SlotBuffer() { + delete array; +} + 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()) { - // We have a gap so expunge all our slots 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) { - // Really old message so we dont have it anymore return NULL; } @@ -94,9 +96,9 @@ Slot *SlotBuffer::getSlot(int64_t seqnum) { } if (index >= array->length()) { - return NULL; } + if (head >= tail && index >= head) { return NULL; } diff --git a/version2/src/C/SlotBuffer.h b/version2/src/C/SlotBuffer.h index 7027de6..4122cd1 100644 --- a/version2/src/C/SlotBuffer.h +++ b/version2/src/C/SlotBuffer.h @@ -16,13 +16,13 @@ private: Array *array; int32_t head; int32_t tail; + int64_t oldestseqn; void incrementHead(); void incrementTail(); public: - int64_t oldestseqn; - SlotBuffer(); + ~SlotBuffer(); int32_t size(); int32_t capacity(); void resize(int newsize); -- 2.34.1