ccls/src/resizable_buffer.h
2017-03-21 10:06:22 -07:00

24 lines
540 B
C++

#pragma once
#include <cstddef>
// 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;
private:
size_t capacity_;
};