summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_memorystream.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/cfx_memorystream.h')
-rw-r--r--core/fxcrt/cfx_memorystream.h14
1 files changed, 5 insertions, 9 deletions
diff --git a/core/fxcrt/cfx_memorystream.h b/core/fxcrt/cfx_memorystream.h
index 95f62b6a2c..47e491275c 100644
--- a/core/fxcrt/cfx_memorystream.h
+++ b/core/fxcrt/cfx_memorystream.h
@@ -7,8 +7,9 @@
#ifndef CORE_FXCRT_CFX_MEMORYSTREAM_H_
#define CORE_FXCRT_CFX_MEMORYSTREAM_H_
-#include <vector>
+#include <memory>
+#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/retain_ptr.h"
@@ -26,24 +27,19 @@ class CFX_MemoryStream : public IFX_SeekableStream {
bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
bool Flush() override;
- uint8_t* GetBuffer() {
- return !m_Blocks.empty() ? m_Blocks.front() : nullptr;
- }
+ const uint8_t* GetBuffer() const { return m_data.get(); }
private:
- explicit CFX_MemoryStream(bool bConsecutive);
+ CFX_MemoryStream();
// Takes ownership of |pBuffer|.
CFX_MemoryStream(uint8_t* pBuffer, size_t nSize);
~CFX_MemoryStream() override;
- bool ExpandBlocks(size_t size);
-
- std::vector<uint8_t*> m_Blocks;
+ std::unique_ptr<uint8_t, FxFreeDeleter> m_data;
size_t m_nTotalSize;
size_t m_nCurSize;
size_t m_nCurPos = 0;
- const bool m_bConsecutive;
};
#endif // CORE_FXCRT_CFX_MEMORYSTREAM_H_