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

Side by Side Diff: core/src/fxcrt/fx_extension.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/fx_basic_wstring.cpp ('k') | core/src/fxcrt/fx_xml_composer.cpp » ('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 "extension.h" 8 #include "extension.h"
9 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 9 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
10 #include <wincrypt.h> 10 #include <wincrypt.h>
11 #else 11 #else
12 #include <ctime> 12 #include <ctime>
13 #endif 13 #endif
14 FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocat or) 14 FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode)
15 { 15 {
16 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(pAllocator); 16 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
17 if (pFA && !pFA->Open(fileName, dwMode)) { 17 if (pFA && !pFA->Open(fileName, dwMode)) {
18 pFA->Release(pAllocator); 18 pFA->Release();
19 return NULL; 19 return NULL;
20 } 20 }
21 return (FX_HFILE)pFA; 21 return (FX_HFILE)pFA;
22 } 22 }
23 FX_HFILE FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocat or) 23 FX_HFILE FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode)
24 { 24 {
25 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(pAllocator); 25 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
26 if (pFA && !pFA->Open(fileName, dwMode)) { 26 if (pFA && !pFA->Open(fileName, dwMode)) {
27 pFA->Release(pAllocator); 27 pFA->Release();
28 return NULL; 28 return NULL;
29 } 29 }
30 return (FX_HFILE)pFA; 30 return (FX_HFILE)pFA;
31 } 31 }
32 void FX_File_Close(FX_HFILE hFile, IFX_Allocator* pAllocator) 32 void FX_File_Close(FX_HFILE hFile)
33 { 33 {
34 FXSYS_assert(hFile != NULL); 34 FXSYS_assert(hFile != NULL);
35 ((IFXCRT_FileAccess*)hFile)->Close(); 35 ((IFXCRT_FileAccess*)hFile)->Close();
36 ((IFXCRT_FileAccess*)hFile)->Release(pAllocator); 36 ((IFXCRT_FileAccess*)hFile)->Release();
37 } 37 }
38 FX_FILESIZE FX_File_GetSize(FX_HFILE hFile) 38 FX_FILESIZE FX_File_GetSize(FX_HFILE hFile)
39 { 39 {
40 FXSYS_assert(hFile != NULL); 40 FXSYS_assert(hFile != NULL);
41 return ((IFXCRT_FileAccess*)hFile)->GetSize(); 41 return ((IFXCRT_FileAccess*)hFile)->GetSize();
42 } 42 }
43 FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile) 43 FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile)
44 { 44 {
45 FXSYS_assert(hFile != NULL); 45 FXSYS_assert(hFile != NULL);
46 return ((IFXCRT_FileAccess*)hFile)->GetPosition(); 46 return ((IFXCRT_FileAccess*)hFile)->GetPosition();
(...skipping 26 matching lines...) Expand all
73 FX_BOOL FX_File_Flush(FX_HFILE hFile) 73 FX_BOOL FX_File_Flush(FX_HFILE hFile)
74 { 74 {
75 FXSYS_assert(hFile != NULL); 75 FXSYS_assert(hFile != NULL);
76 return ((IFXCRT_FileAccess*)hFile)->Flush(); 76 return ((IFXCRT_FileAccess*)hFile)->Flush();
77 } 77 }
78 FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile) 78 FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile)
79 { 79 {
80 FXSYS_assert(hFile != NULL); 80 FXSYS_assert(hFile != NULL);
81 return ((IFXCRT_FileAccess*)hFile)->Truncate(szFile); 81 return ((IFXCRT_FileAccess*)hFile)->Truncate(szFile);
82 } 82 }
83 IFX_FileStream* FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes, IFX_Al locator* pAllocator) 83 IFX_FileStream* FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes)
84 { 84 {
85 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(pAllocator); 85 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
86 if (!pFA) { 86 if (!pFA) {
87 return NULL; 87 return NULL;
88 } 88 }
89 if (!pFA->Open(filename, dwModes)) { 89 if (!pFA->Open(filename, dwModes)) {
90 pFA->Release(pAllocator); 90 pFA->Release();
91 return NULL; 91 return NULL;
92 } 92 }
93 if (pAllocator) { 93 return FX_NEW CFX_CRTFileStream(pFA);
94 return FX_NewAtAllocator(pAllocator) CFX_CRTFileStream(pFA, pAllocator);
95 } else {
96 return FX_NEW CFX_CRTFileStream(pFA, pAllocator);
97 }
98 } 94 }
99 IFX_FileStream* FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes, IFX_A llocator* pAllocator) 95 IFX_FileStream* FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes)
100 { 96 {
101 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(pAllocator); 97 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
102 if (!pFA) { 98 if (!pFA) {
103 return NULL; 99 return NULL;
104 } 100 }
105 if (!pFA->Open(filename, dwModes)) { 101 if (!pFA->Open(filename, dwModes)) {
106 pFA->Release(pAllocator); 102 pFA->Release();
107 return NULL; 103 return NULL;
108 } 104 }
109 if (pAllocator) { 105 return FX_NEW CFX_CRTFileStream(pFA);
110 return FX_NewAtAllocator(pAllocator) CFX_CRTFileStream(pFA, pAllocator);
111 } else {
112 return FX_NEW CFX_CRTFileStream(pFA, pAllocator);
113 }
114 } 106 }
115 IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename, IFX_Allocator* pAllocator) 107 IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename)
116 { 108 {
117 return FX_CreateFileStream(filename, FX_FILEMODE_Truncate, pAllocator); 109 return FX_CreateFileStream(filename, FX_FILEMODE_Truncate);
118 } 110 }
119 IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename, IFX_Allocator* pAllocator ) 111 IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename)
120 { 112 {
121 return FX_CreateFileStream(filename, FX_FILEMODE_Truncate, pAllocator); 113 return FX_CreateFileStream(filename, FX_FILEMODE_Truncate);
122 } 114 }
123 IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename, IFX_Allocator* pAllocator) 115 IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename)
124 { 116 {
125 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly, pAllocator); 117 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly);
126 } 118 }
127 IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename, IFX_Allocator* pAllocator) 119 IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename)
128 { 120 {
129 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly, pAllocator); 121 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly);
130 } 122 }
131 IFX_MemoryStream* FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t dwSize, FX_BOO L bTakeOver, IFX_Allocator* pAllocator) 123 IFX_MemoryStream* FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t dwSize, FX_BOO L bTakeOver)
132 { 124 {
133 if (pAllocator) { 125 return FX_NEW CFX_MemoryStream(pBuffer, dwSize, bTakeOver);
134 return FX_NewAtAllocator(pAllocator)CFX_MemoryStream(pBuffer, dwSize, bT akeOver, pAllocator);
135 } else {
136 return FX_NEW CFX_MemoryStream(pBuffer, dwSize, bTakeOver, NULL);
137 }
138 } 126 }
139 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive, IFX_Allocator* pAl locator) 127 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive)
140 { 128 {
141 if (pAllocator) { 129 return FX_NEW CFX_MemoryStream(bConsecutive);
142 return FX_NewAtAllocator(pAllocator)CFX_MemoryStream(bConsecutive, pAllo cator);
143 } else {
144 return FX_NEW CFX_MemoryStream(bConsecutive, NULL);
145 }
146 } 130 }
147 #ifdef __cplusplus 131 #ifdef __cplusplus
148 extern "C" { 132 extern "C" {
149 #endif 133 #endif
150 FX_FLOAT FXSYS_tan(FX_FLOAT a) 134 FX_FLOAT FXSYS_tan(FX_FLOAT a)
151 { 135 {
152 return (FX_FLOAT)tan(a); 136 return (FX_FLOAT)tan(a);
153 } 137 }
154 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) 138 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x)
155 { 139 {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 { 376 {
393 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 377 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
394 FX_GenerateCryptoRandom(pBuffer, iCount); 378 FX_GenerateCryptoRandom(pBuffer, iCount);
395 #else 379 #else
396 FX_Random_GenerateBase(pBuffer, iCount); 380 FX_Random_GenerateBase(pBuffer, iCount);
397 #endif 381 #endif
398 } 382 }
399 #ifdef __cplusplus 383 #ifdef __cplusplus
400 } 384 }
401 #endif 385 #endif
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_wstring.cpp ('k') | core/src/fxcrt/fx_xml_composer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698