projects
/
iotcloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bug fixes + tabbing
[iotcloud.git]
/
version2
/
src
/
C
/
SlotBuffer.cc
diff --git
a/version2/src/C/SlotBuffer.cc
b/version2/src/C/SlotBuffer.cc
index de4bbe0bc64a43f14851d46b2eb401dbeacbc409..aa217ac17dda116f1ca2c48c3d498a93d182ae9d 100644
(file)
--- a/
version2/src/C/SlotBuffer.cc
+++ b/
version2/src/C/SlotBuffer.cc
@@
-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;
@@
-24,7
+28,7
@@
int SlotBuffer::capacity() {
}
void SlotBuffer::resize(int newsize) {
}
void SlotBuffer::resize(int newsize) {
- if (newsize == (array->length() - 1))
+ if (
(uint32_t)
newsize == (array->length() - 1))
return;
Array<Slot *> *newarray = new Array<Slot *>(newsize + 1);
return;
Array<Slot *> *newarray = new Array<Slot *>(newsize + 1);
@@
-32,7
+36,7
@@
void SlotBuffer::resize(int newsize) {
int index = tail;
for (int i = 0; i < currsize; i++) {
newarray->set(i, array->get(index));
int index = tail;
for (int i = 0; i < currsize; i++) {
newarray->set(i, array->get(index));
- if ((
++
index) == array->length())
+ if ((
(uint32_t)++
index) == array->length())
index = 0;
}
array = newarray;
index = 0;
}
array = newarray;
@@
-42,13
+46,13
@@
void SlotBuffer::resize(int newsize) {
void SlotBuffer::incrementHead() {
head++;
void SlotBuffer::incrementHead() {
head++;
- if (
head
>= array->length())
+ if (
((uint32_t)head)
>= array->length())
head = 0;
}
void SlotBuffer::incrementTail() {
tail++;
head = 0;
}
void SlotBuffer::incrementTail() {
tail++;
- if (
tail
>= array->length())
+ if (
((uint32_t)tail)
>= array->length())
tail = 0;
}
tail = 0;
}
@@
-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,21
+85,20
@@
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;
}
- if (
index
>= array->length()) {
+ if (
((uint32_t)index)
>= array->length()) {
if (head >= tail) {
return NULL;
}
if (head >= tail) {
return NULL;
}
- index -= array->length();
+ index -=
(int32_t)
array->length();
}
}
- if (index >= array->length()) {
-
+ if (((uint32_t)index) >= array->length()) {
return NULL;
}
return NULL;
}
+
if (head >= tail && index >= head) {
return NULL;
}
if (head >= tail && index >= head) {
return NULL;
}