Use DataVector<T> in remaining files.
Easier to write than std::vector<T, FxAllocAllocator<T>>. Update
remaining code that have not been converted by prior CLs.
Change-Id: If761082be1f83a653b700074c12f2810f1895b57
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/96572
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp
index 6e0019e..0215a21 100644
--- a/core/fpdfapi/edit/cpdf_creator.cpp
+++ b/core/fpdfapi/edit/cpdf_creator.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/edit/cpdf_creator.h"
+#include <stdint.h>
+
#include <algorithm>
#include <utility>
@@ -21,8 +23,8 @@
#include "core/fpdfapi/parser/cpdf_string.h"
#include "core/fpdfapi/parser/cpdf_syntax_parser.h"
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_extension.h"
-#include "core/fxcrt/fx_memory_wrappers.h"
#include "core/fxcrt/fx_random.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/span_util.h"
@@ -47,7 +49,7 @@
FX_FILESIZE offset_ = 0;
size_t current_length_ = 0;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> buffer_;
+ DataVector<uint8_t> buffer_;
RetainPtr<IFX_RetainableWriteStream> backing_file_;
};
@@ -243,7 +245,7 @@
if (m_iStage == Stage::kWriteIncremental15) {
if (m_IsOriginal && m_SavedOffset > 0) {
static constexpr FX_FILESIZE kBufferSize = 4096;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> buffer(kBufferSize);
+ DataVector<uint8_t> buffer(kBufferSize);
FX_FILESIZE src_size = m_SavedOffset;
m_pParser->GetSyntax()->SetPos(0);
while (src_size) {
diff --git a/core/fpdfapi/font/cfx_cttgsubtable.cpp b/core/fpdfapi/font/cfx_cttgsubtable.cpp
index 9e9c02c..2e8264e 100644
--- a/core/fpdfapi/font/cfx_cttgsubtable.cpp
+++ b/core/fpdfapi/font/cfx_cttgsubtable.cpp
@@ -6,8 +6,11 @@
#include "core/fpdfapi/font/cfx_cttgsubtable.h"
+#include <stdint.h>
+
#include <utility>
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/stl_util.h"
#include "core/fxge/cfx_fontmapper.h"
@@ -202,8 +205,7 @@
FT_Bytes sp = raw;
rec->LookupOrder = GetUInt16(sp);
rec->ReqFeatureIndex = GetUInt16(sp);
- rec->FeatureIndices =
- std::vector<uint16_t, FxAllocAllocator<uint16_t>>(GetUInt16(sp));
+ rec->FeatureIndices = DataVector<uint16_t>(GetUInt16(sp));
for (auto& element : rec->FeatureIndices)
element = GetUInt16(sp);
}
@@ -220,8 +222,7 @@
void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeatureRecord* rec) {
FT_Bytes sp = raw;
rec->FeatureParams = GetUInt16(sp);
- rec->LookupListIndices =
- std::vector<uint16_t, FxAllocAllocator<uint16_t>>(GetUInt16(sp));
+ rec->LookupListIndices = DataVector<uint16_t>(GetUInt16(sp));
for (auto& listIndex : rec->LookupListIndices)
listIndex = GetUInt16(sp);
}
@@ -308,8 +309,7 @@
uint16_t offset = GetUInt16(sp);
auto rec = std::make_unique<TSubTable2>();
rec->Coverage = ParseCoverage(&raw[offset]);
- rec->Substitutes =
- std::vector<uint16_t, FxAllocAllocator<uint16_t>>(GetUInt16(sp));
+ rec->Substitutes = DataVector<uint16_t>(GetUInt16(sp));
for (auto& substitute : rec->Substitutes)
substitute = GetUInt16(sp);
return rec;
diff --git a/core/fpdfapi/font/cfx_cttgsubtable.h b/core/fpdfapi/font/cfx_cttgsubtable.h
index 89ae758..48c0fd9 100644
--- a/core/fpdfapi/font/cfx_cttgsubtable.h
+++ b/core/fpdfapi/font/cfx_cttgsubtable.h
@@ -13,7 +13,7 @@
#include <set>
#include <vector>
-#include "core/fxcrt/fx_memory_wrappers.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxge/freetype/fx_freetype.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
@@ -32,7 +32,7 @@
uint32_t LangSysTag = 0;
uint16_t LookupOrder = 0;
uint16_t ReqFeatureIndex = 0;
- std::vector<uint16_t, FxAllocAllocator<uint16_t>> FeatureIndices;
+ DataVector<uint16_t> FeatureIndices;
};
struct TScriptRecord {
@@ -50,7 +50,7 @@
uint32_t FeatureTag = 0;
uint16_t FeatureParams = 0;
- std::vector<uint16_t, FxAllocAllocator<uint16_t>> LookupListIndices;
+ DataVector<uint16_t> LookupListIndices;
};
struct TRangeRecord {
@@ -72,7 +72,7 @@
explicit TCoverageFormat1(size_t initial_size);
~TCoverageFormat1() override;
- std::vector<uint16_t, FxAllocAllocator<uint16_t>> GlyphArray;
+ DataVector<uint16_t> GlyphArray;
};
struct TCoverageFormat2 final : public TCoverageFormatBase {
@@ -109,7 +109,7 @@
TSubTable2();
~TSubTable2() override;
- std::vector<uint16_t, FxAllocAllocator<uint16_t>> Substitutes;
+ DataVector<uint16_t> Substitutes;
};
struct TLookup {
diff --git a/core/fpdfapi/font/cpdf_cmap.h b/core/fpdfapi/font/cpdf_cmap.h
index 821df5d..5ce9496 100644
--- a/core/fpdfapi/font/cpdf_cmap.h
+++ b/core/fpdfapi/font/cpdf_cmap.h
@@ -7,10 +7,12 @@
#ifndef CORE_FPDFAPI_FONT_CPDF_CMAP_H_
#define CORE_FPDFAPI_FONT_CPDF_CMAP_H_
+#include <stdint.h>
+
#include <vector>
#include "core/fpdfapi/font/cpdf_cidfont.h"
-#include "core/fxcrt/fx_memory_wrappers.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
#include "third_party/base/span.h"
@@ -90,7 +92,7 @@
CIDCoding m_Coding = CIDCoding::kUNKNOWN;
std::vector<bool> m_MixedTwoByteLeadingBytes;
std::vector<CodeRange> m_MixedFourByteLeadingRanges;
- std::vector<uint16_t, FxAllocAllocator<uint16_t>> m_DirectCharcodeToCIDTable;
+ DataVector<uint16_t> m_DirectCharcodeToCIDTable;
std::vector<CIDRange> m_AdditionalCharcodeToCIDMappings;
UnownedPtr<const FXCMAP_CMap> m_pEmbedMap;
};
diff --git a/core/fpdfapi/render/cpdf_docrenderdata.cpp b/core/fpdfapi/render/cpdf_docrenderdata.cpp
index 12609d3..8887b42 100644
--- a/core/fpdfapi/render/cpdf_docrenderdata.cpp
+++ b/core/fpdfapi/render/cpdf_docrenderdata.cpp
@@ -6,11 +6,12 @@
#include "core/fpdfapi/render/cpdf_docrenderdata.h"
+#include <stdint.h>
+
#include <algorithm>
#include <array>
#include <memory>
#include <utility>
-#include <vector>
#include "core/fpdfapi/font/cpdf_type3font.h"
#include "core/fpdfapi/page/cpdf_dib.h"
@@ -19,6 +20,7 @@
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/render/cpdf_type3cache.h"
+#include "core/fxcrt/data_vector.h"
#if BUILDFLAG(IS_WIN)
#include "core/fxge/win32/cfx_psfonttracker.h"
@@ -96,12 +98,9 @@
std::fill(std::begin(output), std::end(output), 0.0f);
bool bIdentity = true;
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> samples_r(
- CPDF_TransferFunc::kChannelSampleSize);
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> samples_g(
- CPDF_TransferFunc::kChannelSampleSize);
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> samples_b(
- CPDF_TransferFunc::kChannelSampleSize);
+ DataVector<uint8_t> samples_r(CPDF_TransferFunc::kChannelSampleSize);
+ DataVector<uint8_t> samples_g(CPDF_TransferFunc::kChannelSampleSize);
+ DataVector<uint8_t> samples_b(CPDF_TransferFunc::kChannelSampleSize);
std::array<pdfium::span<uint8_t>, 3> samples = {samples_r, samples_g,
samples_b};
for (size_t v = 0; v < CPDF_TransferFunc::kChannelSampleSize; ++v) {
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index d9ba042..295fae9 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/render/cpdf_renderstatus.h"
+#include <stdint.h>
+
#include <algorithm>
#include <memory>
#include <numeric>
@@ -50,6 +52,7 @@
#include "core/fpdfapi/render/cpdf_textrenderer.h"
#include "core/fpdfapi/render/cpdf_type3cache.h"
#include "core/fxcrt/autorestorer.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_system.h"
@@ -1442,7 +1445,7 @@
int dest_pitch = pMask->GetPitch();
uint8_t* src_buf = bitmap->GetBuffer();
int src_pitch = bitmap->GetPitch();
- std::vector<uint8_t, FxAllocAllocator<uint8_t>> transfers(256);
+ DataVector<uint8_t> transfers(256);
if (pFunc) {
std::vector<float> results(pFunc->CountOutputs());
for (size_t i = 0; i < transfers.size(); ++i) {
diff --git a/core/fpdfdoc/cpdf_bookmark.cpp b/core/fpdfdoc/cpdf_bookmark.cpp
index f91bce7..75e4936 100644
--- a/core/fpdfdoc/cpdf_bookmark.cpp
+++ b/core/fpdfdoc/cpdf_bookmark.cpp
@@ -6,11 +6,9 @@
#include "core/fpdfdoc/cpdf_bookmark.h"
-#include <vector>
-
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_string.h"
-#include "core/fxcrt/fx_memory_wrappers.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxge/dib/fx_dib.h"
CPDF_Bookmark::CPDF_Bookmark() = default;
@@ -34,7 +32,7 @@
if (!len)
return WideString();
- std::vector<wchar_t, FxAllocAllocator<wchar_t>> buf(len);
+ DataVector<wchar_t> buf(len);
for (size_t i = 0; i < len; i++) {
wchar_t w = title[i];
buf[i] = w > 0x20 ? w : 0x20;
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index e758ede..eb75f96 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -7,6 +7,7 @@
#include "core/fpdftext/cpdf_textpage.h"
#include <math.h>
+#include <stdint.h>
#include <algorithm>
#include <utility>
@@ -22,9 +23,9 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_string.h"
#include "core/fpdftext/unicodenormalizationdata.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_bidi.h"
#include "core/fxcrt/fx_extension.h"
-#include "core/fxcrt/fx_memory_wrappers.h"
#include "core/fxcrt/fx_unicode.h"
#include "core/fxcrt/stl_util.h"
#include "third_party/base/check.h"
@@ -76,16 +77,15 @@
return baseSpace;
}
-std::vector<wchar_t, FxAllocAllocator<wchar_t>> GetUnicodeNormalization(
- wchar_t wch) {
+DataVector<wchar_t> GetUnicodeNormalization(wchar_t wch) {
wch = wch & 0xFFFF;
wchar_t wFind = kUnicodeDataNormalization[wch];
if (!wFind)
- return std::vector<wchar_t, FxAllocAllocator<wchar_t>>(1, wch);
+ return DataVector<wchar_t>(1, wch);
if (wFind >= 0x8000) {
- return std::vector<wchar_t, FxAllocAllocator<wchar_t>>(
- 1, kUnicodeDataNormalizationMap1[wFind - 0x8000]);
+ return DataVector<wchar_t>(1,
+ kUnicodeDataNormalizationMap1[wFind - 0x8000]);
}
wch = wFind & 0x0FFF;
@@ -94,7 +94,7 @@
if (wFind == 4)
wFind = static_cast<wchar_t>(*pMap++);
- return std::vector<wchar_t, FxAllocAllocator<wchar_t>>(pMap, pMap + wFind);
+ return DataVector<wchar_t>(pMap, pMap + wFind);
}
float MaskPercentFilled(const std::vector<bool>& mask,
@@ -669,7 +669,7 @@
return;
}
info2.m_Index = m_TextBuf.GetLength();
- std::vector<wchar_t, FxAllocAllocator<wchar_t>> normalized;
+ DataVector<wchar_t> normalized;
if (wChar >= 0xFB00 && wChar <= 0xFB06)
normalized = GetUnicodeNormalization(wChar);
if (normalized.empty()) {
@@ -695,8 +695,7 @@
}
info2.m_Index = m_TextBuf.GetLength();
wChar = pdfium::unicode::GetMirrorChar(wChar);
- std::vector<wchar_t, FxAllocAllocator<wchar_t>> normalized =
- GetUnicodeNormalization(wChar);
+ DataVector<wchar_t> normalized = GetUnicodeNormalization(wChar);
if (normalized.empty()) {
info2.m_Unicode = wChar;
m_TextBuf.AppendChar(info2.m_Unicode);
diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
index 4103dac..8c881bf 100644
--- a/core/fpdftext/cpdf_textpage.h
+++ b/core/fpdftext/cpdf_textpage.h
@@ -7,13 +7,15 @@
#ifndef CORE_FPDFTEXT_CPDF_TEXTPAGE_H_
#define CORE_FPDFTEXT_CPDF_TEXTPAGE_H_
+#include <stdint.h>
+
#include <deque>
#include <functional>
#include <vector>
#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_coordinates.h"
-#include "core/fxcrt/fx_memory_wrappers.h"
#include "core/fxcrt/unowned_ptr.h"
#include "core/fxcrt/widestring.h"
#include "core/fxcrt/widetext_buffer.h"
@@ -135,7 +137,7 @@
const std::function<bool(const CharInfo&)>& predicate) const;
UnownedPtr<const CPDF_Page> const m_pPage;
- std::vector<uint16_t, FxAllocAllocator<uint16_t>> m_CharIndices;
+ DataVector<uint16_t> m_CharIndices;
std::deque<CharInfo> m_CharList;
std::deque<CharInfo> m_TempCharList;
WideTextBuffer m_TextBuf;
diff --git a/core/fxcrt/css/cfx_cssoutputtextbuf.h b/core/fxcrt/css/cfx_cssoutputtextbuf.h
index eae19d1..0edc242 100644
--- a/core/fxcrt/css/cfx_cssoutputtextbuf.h
+++ b/core/fxcrt/css/cfx_cssoutputtextbuf.h
@@ -7,9 +7,7 @@
#ifndef CORE_FXCRT_CSS_CFX_CSSOUTPUTTEXTBUF_H_
#define CORE_FXCRT_CSS_CFX_CSSOUTPUTTEXTBUF_H_
-#include <vector>
-
-#include "core/fxcrt/fx_memory_wrappers.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/widestring.h"
class CFX_CSSOutputTextBuf {
@@ -23,7 +21,7 @@
WideStringView GetTrailingBlankTrimmedString() const;
protected:
- std::vector<wchar_t, FxAllocAllocator<wchar_t>> m_Buffer;
+ DataVector<wchar_t> m_Buffer;
};
#endif // CORE_FXCRT_CSS_CFX_CSSOUTPUTTEXTBUF_H_
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp
index 345412a..0e65df7 100644
--- a/core/fxcrt/xml/cfx_xmlparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -6,12 +6,15 @@
#include "core/fxcrt/xml/cfx_xmlparser.h"
+#include <stdint.h>
+
#include <algorithm>
#include <iterator>
#include <stack>
#include <utility>
#include "core/fxcrt/cfx_seekablestreamproxy.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_safe_types.h"
@@ -98,7 +101,7 @@
size_t current_buffer_idx = 0;
size_t buffer_size = 0;
- std::vector<wchar_t, FxAllocAllocator<wchar_t>> buffer;
+ DataVector<wchar_t> buffer;
buffer.resize(alloc_size_safe.ValueOrDie());
std::stack<wchar_t> character_to_skip_too_stack;
diff --git a/core/fxcrt/xml/cfx_xmlparser.h b/core/fxcrt/xml/cfx_xmlparser.h
index ed51dfc..d4d5f8e 100644
--- a/core/fxcrt/xml/cfx_xmlparser.h
+++ b/core/fxcrt/xml/cfx_xmlparser.h
@@ -8,9 +8,8 @@
#define CORE_FXCRT_XML_CFX_XMLPARSER_H_
#include <memory>
-#include <vector>
-#include "core/fxcrt/fx_memory_wrappers.h"
+#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/widestring.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
@@ -56,7 +55,7 @@
CFX_XMLNode* current_node_ = nullptr;
RetainPtr<CFX_SeekableStreamProxy> stream_;
- std::vector<wchar_t, FxAllocAllocator<wchar_t>> current_text_;
+ DataVector<wchar_t> current_text_;
size_t xml_plane_size_ = 1024;
absl::optional<size_t> entity_start_;
};