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

Unified Diff: core/fxcrt/fx_extension.cpp

Issue 1994323002: Remove Release() from IFXCRT_FileAccess (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « core/fxcrt/extension.h ('k') | core/fxcrt/fxcrt_posix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcrt/fx_extension.cpp
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 1dddf09fd677a2a581ceab77d253846a3831fc5b..3717e16207c8a43bce0b301ddc2ac1d45b6d0353 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -17,11 +17,7 @@
CFX_CRTFileStream::CFX_CRTFileStream(IFXCRT_FileAccess* pFA)
: m_pFile(pFA), m_dwCount(1) {}
-CFX_CRTFileStream::~CFX_CRTFileStream() {
- if (m_pFile) {
- m_pFile->Release();
- }
-}
+CFX_CRTFileStream::~CFX_CRTFileStream() {}
IFX_FileStream* CFX_CRTFileStream::Retain() {
m_dwCount++;
@@ -83,27 +79,22 @@ IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) {
#endif // PDF_ENABLE_XFA
IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, uint32_t dwModes) {
- IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
- if (!pFA) {
- return NULL;
- }
- if (!pFA->Open(filename, dwModes)) {
- pFA->Release();
- return NULL;
- }
- return new CFX_CRTFileStream(pFA);
+ std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create());
+ if (!pFA)
Lei Zhang 2016/05/19 22:50:05 IFXCRT_FileAccess::Create() can't fail.
Tom Sepez 2016/05/19 23:18:31 Done.
+ return nullptr;
+ if (!pFA->Open(filename, dwModes))
+ return nullptr;
+ return new CFX_CRTFileStream(pFA.release());
Lei Zhang 2016/05/19 22:50:05 CFX_CRTFileStream should take a unique_ptr. The on
Tom Sepez 2016/05/19 23:18:31 Done.
}
+
IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename,
uint32_t dwModes) {
- IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
- if (!pFA) {
- return NULL;
- }
- if (!pFA->Open(filename, dwModes)) {
- pFA->Release();
- return NULL;
- }
- return new CFX_CRTFileStream(pFA);
+ std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create());
+ if (!pFA)
+ return nullptr;
+ if (!pFA->Open(filename, dwModes))
+ return nullptr;
+ return new CFX_CRTFileStream(pFA.release());
}
IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename) {
return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly);
« no previous file with comments | « core/fxcrt/extension.h ('k') | core/fxcrt/fxcrt_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698