summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp19
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp4
-rw-r--r--core/src/fxcodec/codec/fx_codec.cpp4
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Context.cpp3
-rw-r--r--core/src/fxcodec/jbig2/JBig2_SddProc.cpp14
-rw-r--r--core/src/fxge/ge/fx_ge_fontmap.cpp2
-rw-r--r--samples/image_diff.cc4
-rw-r--r--third_party/base/nonstd_unique_ptr.h12
-rw-r--r--third_party/base/nonstd_unique_ptr_unittest.cpp7
-rw-r--r--third_party/base/stl_util.h15
10 files changed, 31 insertions, 53 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index d5a2780980..2a271f1179 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -327,7 +327,7 @@ FX_DWORD CPDF_Parser::SetEncryptHandler() {
if (!pSecurityHandler->OnInit(this, m_pEncryptDict)) {
return err;
}
- m_pSecurityHandler = nonstd::move(pSecurityHandler);
+ m_pSecurityHandler = std::move(pSecurityHandler);
nonstd::unique_ptr<CPDF_CryptoHandler> pCryptoHandler(
m_pSecurityHandler->CreateCryptoHandler());
if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get())) {
@@ -456,8 +456,7 @@ 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);
- char* pBuf = pdfium::vector_as_array(&buf);
- pBuf[1024 * recordsize] = '\0';
+ buf[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;
@@ -465,12 +464,13 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
if ((FX_FILESIZE)(dwStartPos + dwReadSize) > m_Syntax.m_FileLen) {
return FALSE;
}
- if (!m_Syntax.ReadBlock(reinterpret_cast<uint8_t*>(pBuf), dwReadSize)) {
+ if (!m_Syntax.ReadBlock(reinterpret_cast<uint8_t*>(buf.data()),
+ dwReadSize)) {
return FALSE;
}
for (int32_t i = 0; i < block_size; i++) {
FX_DWORD objnum = start_objnum + block * 1024 + i;
- char* pEntry = pBuf + i * recordsize;
+ char* pEntry = &buf[i * recordsize];
if (pEntry[17] == 'f') {
m_ObjectInfo[objnum].pos = 0;
m_V5Type.SetAtGrow(objnum, 0);
@@ -544,16 +544,15 @@ bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
m_dwXrefStartObjNum = start_objnum;
if (!bSkip) {
std::vector<char> buf(1024 * recordsize + 1);
- char* pBuf = pdfium::vector_as_array(&buf);
- pBuf[1024 * recordsize] = '\0';
+ buf[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;
- m_Syntax.ReadBlock(reinterpret_cast<uint8_t*>(pBuf),
+ m_Syntax.ReadBlock(reinterpret_cast<uint8_t*>(buf.data()),
block_size * recordsize);
for (int32_t i = 0; i < block_size; i++) {
FX_DWORD objnum = start_objnum + block * 1024 + i;
- char* pEntry = pBuf + i * recordsize;
+ char* pEntry = &buf[i * recordsize];
if (pEntry[17] == 'f') {
m_ObjectInfo[objnum].pos = 0;
m_V5Type.SetAtGrow(objnum, 0);
@@ -3606,7 +3605,7 @@ FX_BOOL CPDF_DataAvail::CheckHintTables(IFX_DownloadHints* pHints) {
ParseIndirectObjectAt(szHSStart, 0));
CPDF_Stream* pStream = ToStream(pHintStream.get());
if (pStream && pHintTables->LoadHintStream(pStream))
- m_pHintTables = nonstd::move(pHintTables);
+ m_pHintTables = std::move(pHintTables);
m_docStatus = PDF_DATAAVAIL_DONE;
return TRUE;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
index ea6195dc8e..0afd8f072a 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -6,6 +6,8 @@
#include "render_int.h"
+#include <utility>
+
#include "core/include/fpdfapi/fpdf_module.h"
#include "core/include/fpdfapi/fpdf_pageobj.h"
#include "core/include/fpdfapi/fpdf_render.h"
@@ -126,7 +128,7 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
pBackdrop1->Clear((FX_DWORD)-1);
pBackdrop1->CompositeBitmap(0, 0, pBackdrop->GetWidth(),
pBackdrop->GetHeight(), pBackdrop.get(), 0, 0);
- pBackdrop = nonstd::move(pBackdrop1);
+ pBackdrop = std::move(pBackdrop1);
m_pDevice->SetDIBits(pBackdrop.get(), back_left, back_top);
}
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index 6998114f83..b7b5563b29 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -1,4 +1,3 @@
-
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +7,7 @@
#include "core/include/fxcodec/fx_codec.h"
#include <cmath>
+#include <utility>
#include "codec_int.h"
#include "core/include/fxcrt/fx_ext.h"
@@ -139,7 +139,7 @@ void CCodec_ScanlineDecoder::DownScale(int dest_width, int dest_height) {
if (!cache->AllocateCache())
return;
- m_pDataCache = nonstd::move(cache);
+ m_pDataCache = std::move(cache);
}
FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf,
diff --git a/core/src/fxcodec/jbig2/JBig2_Context.cpp b/core/src/fxcodec/jbig2/JBig2_Context.cpp
index 2a28185d88..9503fed95e 100644
--- a/core/src/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_Context.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
#include <list>
+#include <utility>
#include <vector>
#include "core/src/fxcodec/jbig2/JBig2_ArithDecoder.h"
@@ -1119,7 +1120,7 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
}
}
pGRD->USESKIP = 0;
- m_pGRD = nonstd::move(pGRD);
+ m_pGRD = std::move(pGRD);
}
pSegment->m_nResultType = JBIG2_IMAGE_POINTER;
if (m_pGRD->MMR == 0) {
diff --git a/core/src/fxcodec/jbig2/JBig2_SddProc.cpp b/core/src/fxcodec/jbig2/JBig2_SddProc.cpp
index 06d6520f3f..e9ce932d91 100644
--- a/core/src/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -18,9 +18,6 @@
#include "core/src/fxcodec/jbig2/JBig2_SymbolDict.h"
#include "core/src/fxcodec/jbig2/JBig2_TrdProc.h"
#include "third_party/base/nonstd_unique_ptr.h"
-#include "third_party/base/stl_util.h"
-
-using pdfium::vector_as_array;
CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
CJBig2_ArithDecoder* pArithDecoder,
@@ -110,7 +107,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
pGRD->GBAT[5] = SDAT[5];
pGRD->GBAT[6] = SDAT[6];
pGRD->GBAT[7] = SDAT[7];
- BS = pGRD->decode_Arith(pArithDecoder, vector_as_array(gbContext));
+ BS = pGRD->decode_Arith(pArithDecoder, gbContext->data());
if (!BS) {
goto failed;
}
@@ -198,8 +195,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
ids.IARDX = IARDX.get();
ids.IARDY = IARDY.get();
ids.IAID = IAID.get();
- BS = pDecoder->decode_Arith(pArithDecoder, vector_as_array(grContext),
- &ids);
+ BS = pDecoder->decode_Arith(pArithDecoder, grContext->data(), &ids);
if (!BS) {
FX_Free(SBSYMS);
goto failed;
@@ -234,7 +230,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
pGRRD->GRAT[1] = SDRAT[1];
pGRRD->GRAT[2] = SDRAT[2];
pGRRD->GRAT[3] = SDRAT[3];
- BS = pGRRD->decode(pArithDecoder, vector_as_array(grContext));
+ BS = pGRRD->decode(pArithDecoder, grContext->data());
if (!BS) {
FX_Free(SBSYMS);
goto failed;
@@ -448,7 +444,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman(
pDecoder->SBRAT[1] = SDRAT[1];
pDecoder->SBRAT[2] = SDRAT[2];
pDecoder->SBRAT[3] = SDRAT[3];
- BS = pDecoder->decode_Huffman(pStream, vector_as_array(grContext));
+ BS = pDecoder->decode_Huffman(pStream, grContext->data());
if (!BS) {
FX_Free(SBSYMCODES);
FX_Free(SBSYMS);
@@ -520,7 +516,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman(
pGRRD->GRAT[3] = SDRAT[3];
nonstd::unique_ptr<CJBig2_ArithDecoder> pArithDecoder(
new CJBig2_ArithDecoder(pStream));
- BS = pGRRD->decode(pArithDecoder.get(), vector_as_array(grContext));
+ BS = pGRRD->decode(pArithDecoder.get(), grContext->data());
if (!BS) {
FX_Free(SBSYMS);
goto failed;
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index 1101da2344..dadcf1c66b 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -711,7 +711,7 @@ CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) {
return CFX_ByteString();
std::vector<uint8_t> buffer(size);
- uint8_t* buffer_ptr = pdfium::vector_as_array(&buffer);
+ uint8_t* buffer_ptr = buffer.data();
FX_DWORD bytes_read =
m_pFontInfo->GetFontData(hFont, kTableNAME, buffer_ptr, size);
return (bytes_read == size) ? GetNameFromTT(buffer_ptr, 6) : CFX_ByteString();
diff --git a/samples/image_diff.cc b/samples/image_diff.cc
index 88a3956d09..d24652910f 100644
--- a/samples/image_diff.cc
+++ b/samples/image_diff.cc
@@ -80,8 +80,8 @@ class Image {
fclose(f);
- if (!image_diff_png::DecodePNG(&compressed[0], compressed.size(),
- &data_, &w_, &h_)) {
+ if (!image_diff_png::DecodePNG(compressed.data(), compressed.size(), &data_,
+ &w_, &h_)) {
Clear();
return false;
}
diff --git a/third_party/base/nonstd_unique_ptr.h b/third_party/base/nonstd_unique_ptr.h
index f519b345b1..f056e50397 100644
--- a/third_party/base/nonstd_unique_ptr.h
+++ b/third_party/base/nonstd_unique_ptr.h
@@ -74,18 +74,12 @@
#include <stdlib.h>
#include <ostream>
+#include <utility>
#include "template_util.h"
namespace nonstd {
-// Replacement for move, but doesn't allow things that are already
-// rvalue references.
-template <class T>
-T&& move(T& t) {
- return static_cast<T&&>(t);
-}
-
// Function object which deletes its parameter, which must be a pointer.
// If C is an array type, invokes 'delete[]' on the parameter; otherwise,
// invokes 'delete'. The default deleter for unique_ptr<T>.
@@ -244,7 +238,7 @@ class unique_ptr : public internal::unique_ptr_base<C, D> {
// Move constructor.
unique_ptr(unique_ptr&& that)
- : internal::unique_ptr_base<C, D>(nonstd::move(that)) {}
+ : internal::unique_ptr_base<C, D>(std::move(that)) {}
// operator=. Allows assignment from a nullptr. Deletes the currently owned
// object, if any.
@@ -317,7 +311,7 @@ class unique_ptr<C[], D> : public internal::unique_ptr_base<C, D> {
// Move constructor.
unique_ptr(unique_ptr&& that)
- : internal::unique_ptr_base<C, D>(nonstd::move(that)) {}
+ : internal::unique_ptr_base<C, D>(std::move(that)) {}
// operator=. Allows assignment from a nullptr. Deletes the currently owned
// array, if any.
diff --git a/third_party/base/nonstd_unique_ptr_unittest.cpp b/third_party/base/nonstd_unique_ptr_unittest.cpp
index 2b120581f4..1dcfe48b02 100644
--- a/third_party/base/nonstd_unique_ptr_unittest.cpp
+++ b/third_party/base/nonstd_unique_ptr_unittest.cpp
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <sstream>
+#include <utility>
#include "testing/gtest/include/gtest/gtest.h"
#include "macros.h"
@@ -65,20 +66,20 @@ TEST(UniquePtrTest, MoveTest) {
EXPECT_EQ(1, constructed);
EXPECT_TRUE(ptr1);
- unique_ptr<CtorDtorLogger> ptr2(nonstd::move(ptr1));
+ unique_ptr<CtorDtorLogger> ptr2(std::move(ptr1));
EXPECT_EQ(1, constructed);
EXPECT_FALSE(ptr1);
EXPECT_TRUE(ptr2);
unique_ptr<CtorDtorLogger> ptr3;
- ptr3 = nonstd::move(ptr2);
+ ptr3 = std::move(ptr2);
EXPECT_EQ(1, constructed);
EXPECT_FALSE(ptr2);
EXPECT_TRUE(ptr3);
unique_ptr<CtorDtorLogger> ptr4(new CtorDtorLogger(&constructed4));
EXPECT_EQ(1, constructed4);
- ptr4 = nonstd::move(ptr3);
+ ptr4 = std::move(ptr3);
EXPECT_EQ(0, constructed4);
EXPECT_FALSE(ptr3);
EXPECT_TRUE(ptr4);
diff --git a/third_party/base/stl_util.h b/third_party/base/stl_util.h
index 50e9341569..32656038c1 100644
--- a/third_party/base/stl_util.h
+++ b/third_party/base/stl_util.h
@@ -5,23 +5,8 @@
#ifndef PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
#define PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_
-#include <vector>
-
namespace pdfium {
-// To treat a possibly-empty vector as an array, use these functions.
-// If you know the array will never be empty, you can use &*v.begin()
-// directly, but that is undefined behaviour if |v| is empty.
-template <typename T>
-inline T* vector_as_array(std::vector<T>* v) {
- return v->empty() ? nullptr : &*v->begin();
-}
-
-template <typename T>
-inline const T* vector_as_array(const std::vector<T>* v) {
- return v->empty() ? nullptr : &*v->begin();
-}
-
// Test to see if a set, map, hash_set or hash_map contains a particular key.
// Returns true if the key is in the collection.
template <typename Collection, typename Key>