summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi
diff options
context:
space:
mode:
authorOliver Chang <ochang@chromium.org>2015-10-26 18:12:34 -0700
committerOliver Chang <ochang@chromium.org>2015-10-26 18:12:34 -0700
commit2de4942d3bfe29649b466120da16b1409d700c25 (patch)
treee3e6a64c8bd10c1a60250f176d410c1f4dfef54a /core/src/fpdfapi
parent7b16ba505adf4885b73b716eb5bc60c12c383441 (diff)
downloadpdfium-2de4942d3bfe29649b466120da16b1409d700c25.tar.xz
Merge to XFA: Remove usage of std::vector::data
Clean merge. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1412823005 . (cherry picked from commit 044c06f11fb5e62f0984f960be2717ab9bcb540d) Review URL: https://codereview.chromium.org/1413693010 .
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index cbbeee6024..8c1a123950 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -9,6 +9,7 @@
#include <vector>
#include "../../../../third_party/base/nonstd_unique_ptr.h"
+#include "../../../../third_party/base/stl_util.h"
#include "../../../include/fpdfapi/fpdf_module.h"
#include "../../../include/fpdfapi/fpdf_page.h"
#include "../../../include/fpdfapi/fpdf_parser.h"
@@ -436,7 +437,8 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
FX_FILESIZE SavedPos = m_Syntax.SavePos();
const int32_t recordsize = 20;
std::vector<char> buf(1024 * recordsize + 1);
- buf[1024 * recordsize] = '\0';
+ char* pBuf = pdfium::vector_as_array(&buf);
+ pBuf[1024 * recordsize] = '\0';
int32_t nBlocks = count / 1024 + 1;
for (int32_t block = 0; block < nBlocks; block++) {
int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024;
@@ -444,12 +446,12 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
if ((FX_FILESIZE)(dwStartPos + dwReadSize) > m_Syntax.m_FileLen) {
return FALSE;
}
- if (!m_Syntax.ReadBlock((uint8_t*)buf.data(), dwReadSize)) {
+ if (!m_Syntax.ReadBlock(reinterpret_cast<uint8_t*>(pBuf), dwReadSize)) {
return FALSE;
}
for (int32_t i = 0; i < block_size; i++) {
FX_DWORD objnum = start_objnum + block * 1024 + i;
- char* pEntry = buf.data() + i * recordsize;
+ char* pEntry = pBuf + i * recordsize;
if (pEntry[17] == 'f') {
m_CrossRef.SetAtGrow(objnum, 0);
m_V5Type.SetAtGrow(objnum, 0);
@@ -528,15 +530,17 @@ bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
m_dwXrefStartObjNum = start_objnum;
if (!bSkip) {
std::vector<char> buf(1024 * recordsize + 1);
- buf[1024 * recordsize] = '\0';
+ char* pBuf = pdfium::vector_as_array(&buf);
+ pBuf[1024 * recordsize] = '\0';
int32_t nBlocks = count / 1024 + 1;
FX_BOOL bFirstBlock = TRUE;
for (int32_t block = 0; block < nBlocks; block++) {
int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024;
- m_Syntax.ReadBlock((uint8_t*)buf.data(), block_size * recordsize);
+ m_Syntax.ReadBlock(reinterpret_cast<uint8_t*>(pBuf),
+ block_size * recordsize);
for (int32_t i = 0; i < block_size; i++) {
FX_DWORD objnum = start_objnum + block * 1024 + i;
- char* pEntry = buf.data() + i * recordsize;
+ char* pEntry = pBuf + i * recordsize;
if (pEntry[17] == 'f') {
if (bFirstItem) {
objnum = 0;