ccls/src/resizable_buffer.h

24 lines
540 B
C
Raw Normal View History

2017-03-19 22:06:22 +00:00
#pragma once
2017-03-21 17:06:22 +00:00
#include <cstddef>
2017-03-19 22:06:22 +00:00
// Points to a generic block of memory that can be resized. This class owns
// and has the only pointer to the underlying memory buffer.
struct ResizableBuffer {
ResizableBuffer();
ResizableBuffer(const ResizableBuffer&) = delete;
~ResizableBuffer();
void Append(void* content, size_t content_size);
void Reset();
// Buffer content.
void* buffer;
// Number of bytes in |buffer|. Note that the actual buffer may be larger
// than |size|.
size_t size;
2017-03-19 22:08:36 +00:00
private:
2017-03-19 22:06:22 +00:00
size_t capacity_;
2017-03-21 17:06:22 +00:00
};