summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_basic_buffer.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-08-30 16:21:36 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-30 20:50:28 +0000
commitcd07123993c2f6cfd2d08929e6ad27cab3ac74e9 (patch)
tree9a721335cc507c101557bec84d9022d7f971445a /core/fxcrt/fx_basic_buffer.cpp
parent5624fe39db570f5ad0fab80cf6314e95e4397698 (diff)
downloadpdfium-cd07123993c2f6cfd2d08929e6ad27cab3ac74e9.tar.xz
Move CFX_BinaryBuf out of fx_basic
This CL splits the CFX_BinaryBuf out of fx_basic into its own files. The various includes have been updated. Change-Id: I0fa616eeb4df6dd229c02dc3a0597b3dced59425 Reviewed-on: https://pdfium-review.googlesource.com/12412 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_basic_buffer.cpp')
-rw-r--r--core/fxcrt/fx_basic_buffer.cpp82
1 files changed, 0 insertions, 82 deletions
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp
index b93c1bc9da..e282aa4247 100644
--- a/core/fxcrt/fx_basic_buffer.cpp
+++ b/core/fxcrt/fx_basic_buffer.cpp
@@ -13,88 +13,6 @@
#include "core/fxcrt/fx_safe_types.h"
#include "third_party/base/numerics/safe_conversions.h"
-CFX_BinaryBuf::CFX_BinaryBuf()
- : m_AllocStep(0), m_AllocSize(0), m_DataSize(0) {}
-
-CFX_BinaryBuf::CFX_BinaryBuf(FX_STRSIZE size)
- : m_AllocStep(0), m_AllocSize(size), m_DataSize(size) {
- m_pBuffer.reset(FX_Alloc(uint8_t, size));
-}
-
-CFX_BinaryBuf::~CFX_BinaryBuf() {}
-
-void CFX_BinaryBuf::Delete(FX_STRSIZE start_index, FX_STRSIZE count) {
- if (!m_pBuffer || start_index < 0 || count < 0 || count > m_DataSize ||
- start_index > m_DataSize - count) {
- return;
- }
- memmove(m_pBuffer.get() + start_index, m_pBuffer.get() + start_index + count,
- m_DataSize - start_index - count);
- m_DataSize -= count;
-}
-
-void CFX_BinaryBuf::Clear() {
- m_DataSize = 0;
-}
-
-std::unique_ptr<uint8_t, FxFreeDeleter> CFX_BinaryBuf::DetachBuffer() {
- m_DataSize = 0;
- m_AllocSize = 0;
- return std::move(m_pBuffer);
-}
-
-void CFX_BinaryBuf::EstimateSize(FX_STRSIZE size, FX_STRSIZE step) {
- m_AllocStep = step;
- if (m_AllocSize < size)
- ExpandBuf(size - m_DataSize);
-}
-
-void CFX_BinaryBuf::ExpandBuf(FX_STRSIZE add_size) {
- FX_SAFE_STRSIZE new_size = m_DataSize;
- new_size += add_size;
- if (m_AllocSize >= new_size.ValueOrDie())
- return;
-
- int alloc_step = std::max(128, m_AllocStep ? m_AllocStep : m_AllocSize / 4);
- new_size += alloc_step - 1; // Quantize, don't combine these lines.
- new_size /= alloc_step;
- new_size *= alloc_step;
- m_AllocSize = new_size.ValueOrDie();
- m_pBuffer.reset(m_pBuffer
- ? FX_Realloc(uint8_t, m_pBuffer.release(), m_AllocSize)
- : FX_Alloc(uint8_t, m_AllocSize));
-}
-
-void CFX_BinaryBuf::AppendBlock(const void* pBuf, FX_STRSIZE size) {
- if (size <= 0)
- return;
-
- ExpandBuf(size);
- if (pBuf) {
- memcpy(m_pBuffer.get() + m_DataSize, pBuf, size);
- } else {
- memset(m_pBuffer.get() + m_DataSize, 0, size);
- }
- m_DataSize += size;
-}
-
-void CFX_BinaryBuf::InsertBlock(FX_STRSIZE pos,
- const void* pBuf,
- FX_STRSIZE size) {
- if (size <= 0)
- return;
-
- ExpandBuf(size);
- memmove(m_pBuffer.get() + pos + size, m_pBuffer.get() + pos,
- m_DataSize - pos);
- if (pBuf) {
- memcpy(m_pBuffer.get() + pos, pBuf, size);
- } else {
- memset(m_pBuffer.get() + pos, 0, size);
- }
- m_DataSize += size;
-}
-
void CFX_WideTextBuf::AppendChar(wchar_t ch) {
ExpandBuf(sizeof(wchar_t));
*(wchar_t*)(m_pBuffer.get() + m_DataSize) = ch;