1
This commit is contained in:
parent
17eb6a687c
commit
b08e735f3c
@ -17,6 +17,7 @@ namespace a8
|
|||||||
}
|
}
|
||||||
buf_ = (char*)malloc(buf_len);
|
buf_ = (char*)malloc(buf_len);
|
||||||
buf_len_ = buf_len;
|
buf_len_ = buf_len;
|
||||||
|
capacity_ = buf_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
FifoBuffer::~FifoBuffer()
|
FifoBuffer::~FifoBuffer()
|
||||||
@ -40,7 +41,11 @@ namespace a8
|
|||||||
if (p != buf_ + head_) {
|
if (p != buf_ + head_) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
BufHead* buf_head = (BufHead*)(p - sizeof(BufHead));
|
||||||
|
head_ += sizeof(BufHead) + buf_head->len;
|
||||||
|
if (head_ >= buf_len_) {
|
||||||
|
head_ = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ namespace a8
|
|||||||
unsigned int buf_len_ = 0;
|
unsigned int buf_len_ = 0;
|
||||||
std::atomic<unsigned int> head_ = 0;
|
std::atomic<unsigned int> head_ = 0;
|
||||||
std::atomic<unsigned int> tail_ = 0;
|
std::atomic<unsigned int> tail_ = 0;
|
||||||
|
std::atomic<unsigned int> capacity_ = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user