Fix small bug in StreamBuffer
This commit is contained in:
@@ -134,6 +134,7 @@ void LuaSnap::snapshot() {
|
|||||||
void LuaSnap::rollback() {
|
void LuaSnap::rollback() {
|
||||||
assert(snapshot_.write_count() != 0);
|
assert(snapshot_.write_count() != 0);
|
||||||
deserialize(&snapshot_);
|
deserialize(&snapshot_);
|
||||||
|
assert(snapshot_.at_eof());
|
||||||
snapshot_.clear();
|
snapshot_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ void StreamBuffer::make_space_slow(int64_t bytes) {
|
|||||||
int64_t existing_size = (buf_hi_ - buf_lo_);
|
int64_t existing_size = (buf_hi_ - buf_lo_);
|
||||||
int64_t desired_size = 8192 + ((data_size + bytes) * 2);
|
int64_t desired_size = 8192 + ((data_size + bytes) * 2);
|
||||||
|
|
||||||
|
// Update some simple things.
|
||||||
|
pre_read_count_ += (read_cursor_ - buf_lo_);
|
||||||
|
lua_reader_data_ = 0;
|
||||||
|
lua_reader_size_ = 0;
|
||||||
|
|
||||||
// Move the data to the beginning of the buffer, or to
|
// Move the data to the beginning of the buffer, or to
|
||||||
// the beginning of a new buffer.
|
// the beginning of a new buffer.
|
||||||
if (fixed_size_) {
|
if (fixed_size_) {
|
||||||
@@ -70,13 +75,8 @@ void StreamBuffer::make_space_slow(int64_t bytes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the pointers to the data region.
|
// Update the pointers to the data region.
|
||||||
pre_read_count_ += (read_cursor_ - buf_lo_);
|
|
||||||
read_cursor_ = buf_lo_;
|
read_cursor_ = buf_lo_;
|
||||||
write_cursor_ = buf_lo_ + data_size;
|
write_cursor_ = buf_lo_ + data_size;
|
||||||
|
|
||||||
// Flush the lua reader data, if any.
|
|
||||||
lua_reader_data_ = 0;
|
|
||||||
lua_reader_size_ = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *StreamBuffer::get_overwrite(int64_t size, int64_t write_count_after) {
|
char *StreamBuffer::get_overwrite(int64_t size, int64_t write_count_after) {
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ public:
|
|||||||
|
|
||||||
// Rewind the read cursor to a previous position.
|
// Rewind the read cursor to a previous position.
|
||||||
void unread_to(int64_t read_count);
|
void unread_to(int64_t read_count);
|
||||||
|
|
||||||
// Use the stream buffer as a lua_Writer.
|
// Use the stream buffer as a lua_Writer.
|
||||||
static int lua_writer(lua_State *L, const void* p, size_t sz, void* ud);
|
static int lua_writer(lua_State *L, const void* p, size_t sz, void* ud);
|
||||||
void *lua_writer_ud();
|
void *lua_writer_ud();
|
||||||
|
|||||||
Reference in New Issue
Block a user