diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-12-09 16:26:21 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-12-09 16:26:21 -0800 |
commit | 035359cd8ddb555fa33b6133db4fd405e4660712 (patch) | |
tree | 89accecac7da250468166168cd502ed7b92c7ce7 /core/src/fxcrt | |
parent | 0c92bed7ade20fe193dce0a481dad48e1be41622 (diff) | |
download | pdfium-035359cd8ddb555fa33b6133db4fd405e4660712.tar.xz |
Get rid of most uses of CFX_PtrArray.
I didn't go whole hog and replace these with std::vector,
but in the mean time, it is silly to cast a typedef for
a template instantiated against void* when we can just
instantiate the template against the actual type.
The ones that remain are actual heterogeneous arrays with
wacky casting.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1518593002 .
Diffstat (limited to 'core/src/fxcrt')
-rw-r--r-- | core/src/fxcrt/extension.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index a23eab5c58..58b0457a7c 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -99,7 +99,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { ~CFX_MemoryStream() override { if (m_dwFlags & FX_MEMSTREAM_TakeOver) { for (int32_t i = 0; i < m_Blocks.GetSize(); i++) { - FX_Free((uint8_t*)m_Blocks[i]); + FX_Free(m_Blocks[i]); } } m_Blocks.RemoveAll(); @@ -134,7 +134,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { m_nCurPos = newPos.ValueOrDie(); if (m_dwFlags & FX_MEMSTREAM_Consecutive) { - FXSYS_memcpy(buffer, (uint8_t*)m_Blocks[0] + (size_t)offset, size); + FXSYS_memcpy(buffer, m_Blocks[0] + (size_t)offset, size); return TRUE; } size_t nStartBlock = (size_t)offset / m_nGrowSize; @@ -144,8 +144,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { if (nRead > size) { nRead = size; } - FXSYS_memcpy( - buffer, (uint8_t*)m_Blocks[(int)nStartBlock] + (size_t)offset, nRead); + FXSYS_memcpy(buffer, m_Blocks[(int)nStartBlock] + (size_t)offset, nRead); buffer = ((uint8_t*)buffer) + nRead; size -= nRead; nStartBlock++; @@ -180,7 +179,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { m_nTotalSize = (m_nCurPos + m_nGrowSize - 1) / m_nGrowSize * m_nGrowSize; if (m_Blocks.GetSize() < 1) { - void* block = FX_Alloc(uint8_t, m_nTotalSize); + uint8_t* block = FX_Alloc(uint8_t, m_nTotalSize); m_Blocks.Add(block); } else { m_Blocks[0] = FX_Realloc(uint8_t, m_Blocks[0], m_nTotalSize); @@ -190,7 +189,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { return FALSE; } } - FXSYS_memcpy((uint8_t*)m_Blocks[0] + (size_t)offset, buffer, size); + FXSYS_memcpy(m_Blocks[0] + (size_t)offset, buffer, size); if (m_nCurSize < m_nCurPos) { m_nCurSize = m_nCurPos; } @@ -214,8 +213,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { if (nWrite > size) { nWrite = size; } - FXSYS_memcpy((uint8_t*)m_Blocks[(int)nStartBlock] + (size_t)offset, - buffer, nWrite); + FXSYS_memcpy(m_Blocks[(int)nStartBlock] + (size_t)offset, buffer, nWrite); buffer = ((uint8_t*)buffer) + nWrite; size -= nWrite; nStartBlock++; @@ -239,7 +237,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { } } uint8_t* GetBuffer() const override { - return m_Blocks.GetSize() ? (uint8_t*)m_Blocks[0] : NULL; + return m_Blocks.GetSize() ? m_Blocks[0] : nullptr; } void AttachBuffer(uint8_t* pBuffer, size_t nSize, @@ -264,7 +262,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { } protected: - CFX_PtrArray m_Blocks; + CFX_ArrayTemplate<uint8_t*> m_Blocks; FX_DWORD m_dwCount; size_t m_nTotalSize; size_t m_nCurSize; |