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

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: include <utility>. 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_platforms.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..197022362fcc408dca6ce6e6e1c79a6c720d0f17 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -4,6 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <utility>
+
#include "core/fxcrt/extension.h"
#include "core/fxcrt/include/fx_basic.h"
#include "core/fxcrt/include/fx_ext.h"
@@ -14,14 +16,10 @@
#include <ctime>
#endif
-CFX_CRTFileStream::CFX_CRTFileStream(IFXCRT_FileAccess* pFA)
- : m_pFile(pFA), m_dwCount(1) {}
+CFX_CRTFileStream::CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA)
+ : m_pFile(std::move(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 +81,18 @@ 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->Open(filename, dwModes))
+ return nullptr;
+ return new CFX_CRTFileStream(std::move(pFA));
}
+
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->Open(filename, dwModes))
+ return nullptr;
+ return new CFX_CRTFileStream(std::move(pFA));
}
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_platforms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698