OLD | NEW |
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 _FXCRT_EXTENSION_IMP_ | 7 #ifndef _FXCRT_EXTENSION_IMP_ |
8 #define _FXCRT_EXTENSION_IMP_ | 8 #define _FXCRT_EXTENSION_IMP_ |
9 | 9 |
10 class IFXCRT_FileAccess | 10 class IFXCRT_FileAccess |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 if (m_bUseRange) { | 223 if (m_bUseRange) { |
224 safeOffset += m_nOffset; | 224 safeOffset += m_nOffset; |
225 } | 225 } |
226 | 226 |
227 if (!safeOffset.IsValid()) { | 227 if (!safeOffset.IsValid()) { |
228 return FALSE; | 228 return FALSE; |
229 } | 229 } |
230 | 230 |
231 offset = safeOffset.ValueOrDie(); | 231 offset = safeOffset.ValueOrDie(); |
232 | 232 |
233 FX_SAFE_SIZET newPos = size; | 233 FX_SAFE_SIZE_T newPos = size; |
234 newPos += offset; | 234 newPos += offset; |
235 if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 || newPos.ValueOr
Die() >= m_nCurSize) { | 235 if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 || newPos.ValueOr
Die() >= m_nCurSize) { |
236 return FALSE; | 236 return FALSE; |
237 } | 237 } |
238 | 238 |
239 m_nCurPos = newPos.ValueOrDie(); | 239 m_nCurPos = newPos.ValueOrDie(); |
240 if (m_dwFlags & FX_MEMSTREAM_Consecutive) { | 240 if (m_dwFlags & FX_MEMSTREAM_Consecutive) { |
241 FXSYS_memcpy32(buffer, (FX_LPBYTE)m_Blocks[0] + (size_t)offset, size
); | 241 FXSYS_memcpy32(buffer, (FX_LPBYTE)m_Blocks[0] + (size_t)offset, size
); |
242 return TRUE; | 242 return TRUE; |
243 } | 243 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 275 } |
276 virtual FX_BOOL WriteBlock(const void* buffer, F
X_FILESIZE offset, size_t size) | 276 virtual FX_BOOL WriteBlock(const void* buffer, F
X_FILESIZE offset, size_t size) |
277 { | 277 { |
278 if (!buffer || !size) { | 278 if (!buffer || !size) { |
279 return FALSE; | 279 return FALSE; |
280 } | 280 } |
281 if (m_bUseRange) { | 281 if (m_bUseRange) { |
282 offset += (FX_FILESIZE)m_nOffset; | 282 offset += (FX_FILESIZE)m_nOffset; |
283 } | 283 } |
284 if (m_dwFlags & FX_MEMSTREAM_Consecutive) { | 284 if (m_dwFlags & FX_MEMSTREAM_Consecutive) { |
285 FX_SAFE_SIZET newPos = size; | 285 FX_SAFE_SIZE_T newPos = size; |
286 newPos += offset; | 286 newPos += offset; |
287 if (!newPos.IsValid()) | 287 if (!newPos.IsValid()) |
288 return FALSE; | 288 return FALSE; |
289 | 289 |
290 m_nCurPos = newPos.ValueOrDie(); | 290 m_nCurPos = newPos.ValueOrDie(); |
291 if (m_nCurPos > m_nTotalSize) { | 291 if (m_nCurPos > m_nTotalSize) { |
292 m_nTotalSize = (m_nCurPos + m_nGrowSize - 1) / m_nGrowSize * m_n
GrowSize; | 292 m_nTotalSize = (m_nCurPos + m_nGrowSize - 1) / m_nGrowSize * m_n
GrowSize; |
293 if (m_Blocks.GetSize() < 1) { | 293 if (m_Blocks.GetSize() < 1) { |
294 void* block = FX_Alloc(FX_BYTE, m_nTotalSize); | 294 void* block = FX_Alloc(FX_BYTE, m_nTotalSize); |
295 m_Blocks.Add(block); | 295 m_Blocks.Add(block); |
296 } else { | 296 } else { |
297 m_Blocks[0] = FX_Realloc(FX_BYTE, m_Blocks[0], m_nTotalSize)
; | 297 m_Blocks[0] = FX_Realloc(FX_BYTE, m_Blocks[0], m_nTotalSize)
; |
298 } | 298 } |
299 if (!m_Blocks[0]) { | 299 if (!m_Blocks[0]) { |
300 m_Blocks.RemoveAll(); | 300 m_Blocks.RemoveAll(); |
301 return FALSE; | 301 return FALSE; |
302 } | 302 } |
303 } | 303 } |
304 FXSYS_memcpy32((FX_LPBYTE)m_Blocks[0] + (size_t)offset, buffer, size
); | 304 FXSYS_memcpy32((FX_LPBYTE)m_Blocks[0] + (size_t)offset, buffer, size
); |
305 if (m_nCurSize < m_nCurPos) { | 305 if (m_nCurSize < m_nCurPos) { |
306 m_nCurSize = m_nCurPos; | 306 m_nCurSize = m_nCurPos; |
307 } | 307 } |
308 return TRUE; | 308 return TRUE; |
309 } | 309 } |
310 | 310 |
311 FX_SAFE_SIZET newPos = size; | 311 FX_SAFE_SIZE_T newPos = size; |
312 newPos += offset; | 312 newPos += offset; |
313 if (!newPos.IsValid()) { | 313 if (!newPos.IsValid()) { |
314 return FALSE; | 314 return FALSE; |
315 } | 315 } |
316 | 316 |
317 if (!ExpandBlocks(newPos.ValueOrDie())) { | 317 if (!ExpandBlocks(newPos.ValueOrDie())) { |
318 return FALSE; | 318 return FALSE; |
319 } | 319 } |
320 m_nCurPos = newPos.ValueOrDie(); | 320 m_nCurPos = newPos.ValueOrDie(); |
321 size_t nStartBlock = (size_t)offset / m_nGrowSize; | 321 size_t nStartBlock = (size_t)offset / m_nGrowSize; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 FX_DWORD mt[MT_N]; | 433 FX_DWORD mt[MT_N]; |
434 } FX_MTRANDOMCONTEXT, * FX_LPMTRANDOMCONTEXT; | 434 } FX_MTRANDOMCONTEXT, * FX_LPMTRANDOMCONTEXT; |
435 typedef FX_MTRANDOMCONTEXT const * FX_LPCMTRANDOMCONTEXT; | 435 typedef FX_MTRANDOMCONTEXT const * FX_LPCMTRANDOMCONTEXT; |
436 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 436 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
437 FX_BOOL FX_GenerateCryptoRandom(FX_LPDWORD pBuffer, FX_INT32 iCount); | 437 FX_BOOL FX_GenerateCryptoRandom(FX_LPDWORD pBuffer, FX_INT32 iCount); |
438 #endif | 438 #endif |
439 #ifdef __cplusplus | 439 #ifdef __cplusplus |
440 } | 440 } |
441 #endif | 441 #endif |
442 #endif | 442 #endif |
OLD | NEW |