| 71 | CMemoryWriter::~CMemoryWriter() { xr_free(data); } |
| 72 | |
| 73 | void CMemoryWriter::w(const void* ptr, size_t count) |
| 74 | { |
| 75 | if (position + count > mem_size) |
| 76 | { |
| 77 | // reallocate |
| 78 | if (mem_size == 0) |
| 79 | mem_size = 1024 * 1024; |
| 80 | while (mem_size <= (position + count)) |
| 81 | mem_size *= 2; |
| 82 | if (0 == data) |
| 83 | data = (BYTE*)xr_malloc(mem_size); |
| 84 | else |
| 85 | data = (BYTE*)xr_realloc(data, mem_size); |
| 86 | } |
| 87 | CopyMemory(data + position, ptr, count); |
| 88 | position += count; |
| 89 | if (position > file_size) |
| 90 | file_size = position; |
| 91 | } |
| 92 | |
| 93 | void CMemoryWriter::reserve(const size_t count) |
| 94 | { |
no test coverage detected