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

Side by Side Diff: core/src/fxcrt/fxcrt_platforms.cpp

Issue 372473003: Remove custom memory manager (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Change malloc to calloc Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fxcrt_platforms.h ('k') | core/src/fxcrt/fxcrt_posix.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../include/fxcrt/fx_ext.h" 7 #include "../../include/fxcrt/fx_ext.h"
8 #include "fxcrt_platforms.h" 8 #include "fxcrt_platforms.h"
9 #if (_FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ && _FXM_PLATFORM_ != _FXM_PLATFORM _LINUX_ && _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ && _FXM_PLATFORM_ != _FXM_PLAT FORM_ANDROID_) 9 #if (_FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ && _FXM_PLATFORM_ != _FXM_PLATFORM _LINUX_ && _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ && _FXM_PLATFORM_ != _FXM_PLAT FORM_ANDROID_)
10 IFXCRT_FileAccess* FXCRT_FileAccess_Create(IFX_Allocator* pAllocator) 10 IFXCRT_FileAccess* FXCRT_FileAccess_Create()
11 { 11 {
12 if (pAllocator) { 12 return FX_NEW CFXCRT_FileAccess_CRT;
13 return FX_NewAtAllocator(pAllocator) CFXCRT_FileAccess_CRT;
14 } else {
15 return FX_NEW CFXCRT_FileAccess_CRT;
16 }
17 } 13 }
18 void FXCRT_GetFileModeString(FX_DWORD dwModes, CFX_ByteString &bsMode) 14 void FXCRT_GetFileModeString(FX_DWORD dwModes, CFX_ByteString &bsMode)
19 { 15 {
20 if (dwModes & FX_FILEMODE_ReadOnly) { 16 if (dwModes & FX_FILEMODE_ReadOnly) {
21 bsMode = FX_BSTRC("rb"); 17 bsMode = FX_BSTRC("rb");
22 } else if (dwModes & FX_FILEMODE_Truncate) { 18 } else if (dwModes & FX_FILEMODE_Truncate) {
23 bsMode = FX_BSTRC("w+b"); 19 bsMode = FX_BSTRC("w+b");
24 } else { 20 } else {
25 bsMode = FX_BSTRC("a+b"); 21 bsMode = FX_BSTRC("a+b");
26 } 22 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return m_hFile != NULL; 60 return m_hFile != NULL;
65 } 61 }
66 void CFXCRT_FileAccess_CRT::Close() 62 void CFXCRT_FileAccess_CRT::Close()
67 { 63 {
68 if (!m_hFile) { 64 if (!m_hFile) {
69 return; 65 return;
70 } 66 }
71 FXSYS_fclose(m_hFile); 67 FXSYS_fclose(m_hFile);
72 m_hFile = NULL; 68 m_hFile = NULL;
73 } 69 }
74 void CFXCRT_FileAccess_CRT::Release(IFX_Allocator* pAllocator) 70 void CFXCRT_FileAccess_CRT::Release()
75 { 71 {
76 if (pAllocator) { 72 delete this;
77 FX_DeleteAtAllocator(this, pAllocator, CFXCRT_FileAccess_CRT);
78 } else {
79 delete this;
80 }
81 } 73 }
82 FX_FILESIZE CFXCRT_FileAccess_CRT::GetSize() const 74 FX_FILESIZE CFXCRT_FileAccess_CRT::GetSize() const
83 { 75 {
84 if (!m_hFile) { 76 if (!m_hFile) {
85 return 0; 77 return 0;
86 } 78 }
87 FX_FILESIZE pos = (FX_FILESIZE)FXSYS_ftell(m_hFile); 79 FX_FILESIZE pos = (FX_FILESIZE)FXSYS_ftell(m_hFile);
88 FXSYS_fseek(m_hFile, 0, FXSYS_SEEK_END); 80 FXSYS_fseek(m_hFile, 0, FXSYS_SEEK_END);
89 FX_FILESIZE size = (FX_FILESIZE)FXSYS_ftell(m_hFile); 81 FX_FILESIZE size = (FX_FILESIZE)FXSYS_ftell(m_hFile);
90 FXSYS_fseek(m_hFile, pos, FXSYS_SEEK_SET); 82 FXSYS_fseek(m_hFile, pos, FXSYS_SEEK_SET);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 186 }
195 FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst) 187 FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst)
196 { 188 {
197 return rename(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); 189 return rename(fileNameSrc.GetCStr(), fileNameDst.GetCStr());
198 } 190 }
199 FX_BOOL FX_File_Move(FX_WSTR fileNameSrc, FX_WSTR fileNameDst) 191 FX_BOOL FX_File_Move(FX_WSTR fileNameSrc, FX_WSTR fileNameDst)
200 { 192 {
201 return FX_File_Move(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); 193 return FX_File_Move(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst));
202 } 194 }
203 #endif 195 #endif
OLDNEW
« no previous file with comments | « core/src/fxcrt/fxcrt_platforms.h ('k') | core/src/fxcrt/fxcrt_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698