Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: core/fpdfapi/page/fpdf_page_parser.cpp

Issue 2384883003: Remove CPDF_Object::Release() in favor of direct delete (Closed)
Patch Set: nits Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/fpdfapi/page/fpdf_page_parser.cpp
diff --git a/core/fpdfapi/page/fpdf_page_parser.cpp b/core/fpdfapi/page/fpdf_page_parser.cpp
index 124bf71189f889be790a06c0a98574a71c1a8b03..737c971b90341c4930e92b302e82cc20b6717151 100644
--- a/core/fpdfapi/page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/page/fpdf_page_parser.cpp
@@ -234,24 +234,19 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
CPDF_StreamContentParser::~CPDF_StreamContentParser() {
ClearAllParams();
FX_Free(m_pPathPoints);
- if (m_pLastImageDict) {
- m_pLastImageDict->Release();
- }
- if (m_pLastCloneImageDict) {
- m_pLastCloneImageDict->Release();
- }
+ delete m_pLastImageDict;
+ delete m_pLastCloneImageDict;
}
int CPDF_StreamContentParser::GetNextParamPos() {
if (m_ParamCount == PARAM_BUF_SIZE) {
m_ParamStartPos++;
- if (m_ParamStartPos == PARAM_BUF_SIZE) {
+ if (m_ParamStartPos == PARAM_BUF_SIZE)
m_ParamStartPos = 0;
- }
- if (m_ParamBuf[m_ParamStartPos].m_Type == 0) {
- if (CPDF_Object* pObject = m_ParamBuf[m_ParamStartPos].m_pObject)
- pObject->Release();
- }
+
+ if (m_ParamBuf[m_ParamStartPos].m_Type == 0)
+ delete m_ParamBuf[m_ParamStartPos].m_pObject;
+
return m_ParamStartPos;
}
int index = m_ParamStartPos + m_ParamCount;
@@ -298,14 +293,12 @@ void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) {
void CPDF_StreamContentParser::ClearAllParams() {
uint32_t index = m_ParamStartPos;
for (uint32_t i = 0; i < m_ParamCount; i++) {
- if (m_ParamBuf[index].m_Type == 0) {
- if (CPDF_Object* pObject = m_ParamBuf[index].m_pObject)
- pObject->Release();
- }
+ if (m_ParamBuf[index].m_Type == 0)
+ delete m_ParamBuf[index].m_pObject;
+
index++;
- if (index == PARAM_BUF_SIZE) {
+ if (index == PARAM_BUF_SIZE)
index = 0;
- }
}
m_ParamStartPos = 0;
m_ParamCount = 0;
@@ -585,7 +578,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
m_pSyntax->GetWordSize());
if (bsKeyword != "ID") {
m_pSyntax->SetPos(savePos);
- pDict->Release();
+ delete pDict;
return;
}
}
@@ -594,8 +587,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1,
m_pSyntax->GetWordSize() - 1);
- std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj(
- m_pSyntax->ReadNextObject(false, 0));
+ std::unique_ptr<CPDF_Object> pObj(m_pSyntax->ReadNextObject(false, 0));
if (!key.IsEmpty()) {
uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
if (dwObjNum)
@@ -638,9 +630,9 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
CPDF_ImageObject* pImgObj = AddImage(pStream, nullptr, true);
if (!pImgObj) {
if (pStream) {
- pStream->Release();
+ delete pStream;
} else {
- pDict->Release();
+ delete pDict;
}
}
}

Powered by Google App Engine
This is Rietveld 408576698