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

Side by Side Diff: core/include/fxcrt/fx_stream.h

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/include/fxcrt/fx_memory.h ('k') | core/include/fxcrt/fx_string.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 #ifndef _FX_STREAM_H_ 7 #ifndef _FX_STREAM_H_
8 #define _FX_STREAM_H_ 8 #define _FX_STREAM_H_
9 #ifndef _FX_MEMORY_H_ 9 #ifndef _FX_MEMORY_H_
10 #include "fx_memory.h" 10 #include "fx_memory.h"
11 #endif 11 #endif
12 void* FX_OpenFolder(FX_LPCSTR path); 12 void* FX_OpenFolder(FX_LPCSTR path);
13 void* FX_OpenFolder(FX_LPCWSTR path); 13 void* FX_OpenFolder(FX_LPCWSTR path);
14 FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder) ; 14 FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder) ;
(...skipping 19 matching lines...) Expand all
34 #define FX_GETBYTEOFFSET40(a) 0 34 #define FX_GETBYTEOFFSET40(a) 0
35 #define FX_GETBYTEOFFSET48(a) 0 35 #define FX_GETBYTEOFFSET48(a) 0
36 #define FX_GETBYTEOFFSET56(a) 0 36 #define FX_GETBYTEOFFSET56(a) 0
37 #define FX_GETBYTEOFFSET24(a) ((FX_BYTE)(a>>24)) 37 #define FX_GETBYTEOFFSET24(a) ((FX_BYTE)(a>>24))
38 #define FX_GETBYTEOFFSET16(a) ((FX_BYTE)(a>>16)) 38 #define FX_GETBYTEOFFSET16(a) ((FX_BYTE)(a>>16))
39 #define FX_GETBYTEOFFSET8(a) ((FX_BYTE)(a>>8)) 39 #define FX_GETBYTEOFFSET8(a) ((FX_BYTE)(a>>8))
40 #define FX_GETBYTEOFFSET0(a) ((FX_BYTE)(a)) 40 #define FX_GETBYTEOFFSET0(a) ((FX_BYTE)(a))
41 #define FX_FILEMODE_Write 0 41 #define FX_FILEMODE_Write 0
42 #define FX_FILEMODE_ReadOnly 1 42 #define FX_FILEMODE_ReadOnly 1
43 #define FX_FILEMODE_Truncate 2 43 #define FX_FILEMODE_Truncate 2
44 FX_HFILE» FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator* p Allocator = NULL); 44 FX_HFILE» FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode);
45 FX_HFILE» FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode, IFX_Allocator* p Allocator = NULL); 45 FX_HFILE» FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode);
46 void» » FX_File_Close(FX_HFILE hFile, IFX_Allocator* pAllocator = NULL); 46 void» » FX_File_Close(FX_HFILE hFile);
47 FX_FILESIZE FX_File_GetSize(FX_HFILE hFile); 47 FX_FILESIZE FX_File_GetSize(FX_HFILE hFile);
48 FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile); 48 FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile);
49 FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos); 49 FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos);
50 size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer); 50 size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer);
51 size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer, FX_FILESIZE pos); 51 size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer, FX_FILESIZE pos);
52 size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuff er); 52 size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuff er);
53 size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szB uffer, FX_FILESIZE pos); 53 size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szB uffer, FX_FILESIZE pos);
54 FX_BOOL FX_File_Flush(FX_HFILE hFile); 54 FX_BOOL FX_File_Flush(FX_HFILE hFile);
55 FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile); 55 FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile);
56 FX_BOOL FX_File_Exist(FX_BSTR fileName); 56 FX_BOOL FX_File_Exist(FX_BSTR fileName);
(...skipping 21 matching lines...) Expand all
78 virtual FX_FILESIZE GetSize() = 0; 78 virtual FX_FILESIZE GetSize() = 0;
79 79
80 virtual FX_BOOL Flush() = 0; 80 virtual FX_BOOL Flush() = 0;
81 81
82 virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZ E offset, size_t size) = 0; 82 virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZ E offset, size_t size) = 0;
83 virtual FX_BOOL WriteBlock(const void* pData, size_t siz e) 83 virtual FX_BOOL WriteBlock(const void* pData, size_t siz e)
84 { 84 {
85 return WriteBlock(pData, GetSize(), size); 85 return WriteBlock(pData, GetSize(), size);
86 } 86 }
87 }; 87 };
88 IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL); 88 IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename);
89 IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL); 89 IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename);
90 class IFX_StreamRead 90 class IFX_StreamRead
91 { 91 {
92 public: 92 public:
93 93
94 virtual void Release() = 0; 94 virtual void Release() = 0;
95 95
96 virtual FX_BOOL IsEOF() = 0; 96 virtual FX_BOOL IsEOF() = 0;
97 97
98 virtual FX_FILESIZE GetPosition() = 0; 98 virtual FX_FILESIZE GetPosition() = 0;
99 99
(...skipping 24 matching lines...) Expand all
124 124
125 virtual void ClearRange() {} 125 virtual void ClearRange() {}
126 126
127 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offs et, size_t size) = 0; 127 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offs et, size_t size) = 0;
128 128
129 virtual size_t ReadBlock(void* buffer, size_t size) 129 virtual size_t ReadBlock(void* buffer, size_t size)
130 { 130 {
131 return 0; 131 return 0;
132 } 132 }
133 }; 133 };
134 IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL); 134 IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename);
135 IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL); 135 IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename);
136 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite 136 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite
137 { 137 {
138 public: 138 public:
139 139
140 virtual IFX_FileStream* Retain() = 0; 140 virtual IFX_FileStream* Retain() = 0;
141 141
142 virtual void Release() = 0; 142 virtual void Release() = 0;
143 143
144 virtual FX_FILESIZE GetSize() = 0; 144 virtual FX_FILESIZE GetSize() = 0;
145 145
146 virtual FX_BOOL IsEOF() = 0; 146 virtual FX_BOOL IsEOF() = 0;
147 147
148 virtual FX_FILESIZE GetPosition() = 0; 148 virtual FX_FILESIZE GetPosition() = 0;
149 149
150 virtual FX_BOOL ReadBlock(void* buffer, FX_FILES IZE offset, size_t size) = 0; 150 virtual FX_BOOL ReadBlock(void* buffer, FX_FILES IZE offset, size_t size) = 0;
151 151
152 virtual size_t ReadBlock(void* buffer, size_t s ize) = 0; 152 virtual size_t ReadBlock(void* buffer, size_t s ize) = 0;
153 153
154 virtual FX_BOOL WriteBlock(const void* buffer, F X_FILESIZE offset, size_t size) = 0; 154 virtual FX_BOOL WriteBlock(const void* buffer, F X_FILESIZE offset, size_t size) = 0;
155 virtual FX_BOOL WriteBlock(const void* buffer, s ize_t size) 155 virtual FX_BOOL WriteBlock(const void* buffer, s ize_t size)
156 { 156 {
157 return WriteBlock(buffer, GetSize(), size); 157 return WriteBlock(buffer, GetSize(), size);
158 } 158 }
159 159
160 virtual FX_BOOL Flush() = 0; 160 virtual FX_BOOL Flush() = 0;
161 }; 161 };
162 IFX_FileStream*»» FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes , IFX_Allocator* pAllocator = NULL); 162 IFX_FileStream*»» FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes );
163 IFX_FileStream*»» FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwMode s, IFX_Allocator* pAllocator = NULL); 163 IFX_FileStream*»» FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwMode s);
164 class IFX_MemoryStream : public IFX_FileStream 164 class IFX_MemoryStream : public IFX_FileStream
165 { 165 {
166 public: 166 public:
167 167
168 virtual FX_BOOL IsConsecutive() const = 0; 168 virtual FX_BOOL IsConsecutive() const = 0;
169 169
170 virtual void EstimateSize(size_t nInitSize, size_t nG rowSize) = 0; 170 virtual void EstimateSize(size_t nInitSize, size_t nG rowSize) = 0;
171 171
172 virtual FX_LPBYTE GetBuffer() const = 0; 172 virtual FX_LPBYTE GetBuffer() const = 0;
173 173
174 virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t n Size, FX_BOOL bTakeOver = FALSE) = 0; 174 virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t n Size, FX_BOOL bTakeOver = FALSE) = 0;
175 175
176 virtual void DetachBuffer() = 0; 176 virtual void DetachBuffer() = 0;
177 }; 177 };
178 IFX_MemoryStream*» FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, F X_BOOL bTakeOver = FALSE, IFX_Allocator* pAllocator = NULL); 178 IFX_MemoryStream*» FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, F X_BOOL bTakeOver = FALSE);
179 IFX_MemoryStream*» FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE, IFX_ Allocator* pAllocator = NULL); 179 IFX_MemoryStream*» FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
180 class IFX_BufferRead : public IFX_StreamRead 180 class IFX_BufferRead : public IFX_StreamRead
181 { 181 {
182 public: 182 public:
183 183
184 virtual void Release() = 0; 184 virtual void Release() = 0;
185 185
186 virtual FX_BOOL IsEOF() = 0; 186 virtual FX_BOOL IsEOF() = 0;
187 187
188 virtual FX_FILESIZE GetPosition() = 0; 188 virtual FX_FILESIZE GetPosition() = 0;
189 189
190 virtual size_t ReadBlock(void* buffer, size_t size) = 0 ; 190 virtual size_t ReadBlock(void* buffer, size_t size) = 0 ;
191 191
192 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0; 192 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
193 193
194 virtual FX_LPCBYTE GetBlockBuffer() = 0; 194 virtual FX_LPCBYTE GetBlockBuffer() = 0;
195 195
196 virtual size_t GetBlockSize() = 0; 196 virtual size_t GetBlockSize() = 0;
197 197
198 virtual FX_FILESIZE GetBlockOffset() = 0; 198 virtual FX_FILESIZE GetBlockOffset() = 0;
199 }; 199 };
200 #endif 200 #endif
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_memory.h ('k') | core/include/fxcrt/fx_string.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698