1
This commit is contained in:
parent
eea166429d
commit
17eb6a687c
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
#include <a8/fifobuffer.h>
|
#include <a8/fifobuffer.h>
|
||||||
|
|
||||||
|
struct BufHead
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
};
|
||||||
|
|
||||||
namespace a8
|
namespace a8
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -26,12 +31,19 @@ namespace a8
|
|||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
unsigned int real_len = len + 4;
|
unsigned int real_len = len + sizeof(BufHead);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoBuffer::Free(char* p)
|
void FifoBuffer::Free(char* p)
|
||||||
{
|
{
|
||||||
|
if (p >= buf_ && p < buf_ + buf_len_) {
|
||||||
|
if (p != buf_ + head_) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ namespace a8
|
|||||||
|
|
||||||
char* buf_ = nullptr;
|
char* buf_ = nullptr;
|
||||||
unsigned int buf_len_ = 0;
|
unsigned int buf_len_ = 0;
|
||||||
std::atomic<unsigned int> start_ = 0;
|
std::atomic<unsigned int> head_ = 0;
|
||||||
std::atomic<unsigned int> end_ = 0;
|
std::atomic<unsigned int> tail_ = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user