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

Side by Side Diff: core/src/fxcrt/extension.h

Issue 1171733003: Remove typdefs for pointer types in fx_system.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual fixes. Created 5 years, 6 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/fxcodec/jbig2/JBig2_Segment.h ('k') | core/src/fxcrt/fx_basic_array.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 #ifndef CORE_SRC_FXCRT_EXTENSION_H_ 7 #ifndef CORE_SRC_FXCRT_EXTENSION_H_
8 #define CORE_SRC_FXCRT_EXTENSION_H_ 8 #define CORE_SRC_FXCRT_EXTENSION_H_
9 9
10 #include "../../include/fxcrt/fx_safe_types.h" 10 #include "../../include/fxcrt/fx_safe_types.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 CFX_MemoryStream(FX_BOOL bConsecutive) 139 CFX_MemoryStream(FX_BOOL bConsecutive)
140 : m_dwCount(1) 140 : m_dwCount(1)
141 , m_nTotalSize(0) 141 , m_nTotalSize(0)
142 , m_nCurSize(0) 142 , m_nCurSize(0)
143 , m_nCurPos(0) 143 , m_nCurPos(0)
144 , m_nGrowSize(FX_MEMSTREAM_BlockSize) 144 , m_nGrowSize(FX_MEMSTREAM_BlockSize)
145 , m_bUseRange(FALSE) 145 , m_bUseRange(FALSE)
146 { 146 {
147 m_dwFlags = FX_MEMSTREAM_TakeOver | (bConsecutive ? FX_MEMSTREAM_Consecu tive : 0); 147 m_dwFlags = FX_MEMSTREAM_TakeOver | (bConsecutive ? FX_MEMSTREAM_Consecu tive : 0);
148 } 148 }
149 CFX_MemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver) 149 CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver)
150 : m_dwCount(1) 150 : m_dwCount(1)
151 , m_nTotalSize(nSize) 151 , m_nTotalSize(nSize)
152 , m_nCurSize(nSize) 152 , m_nCurSize(nSize)
153 , m_nCurPos(0) 153 , m_nCurPos(0)
154 , m_nGrowSize(FX_MEMSTREAM_BlockSize) 154 , m_nGrowSize(FX_MEMSTREAM_BlockSize)
155 , m_bUseRange(FALSE) 155 , m_bUseRange(FALSE)
156 { 156 {
157 m_Blocks.Add(pBuffer); 157 m_Blocks.Add(pBuffer);
158 m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOve r : 0); 158 m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOve r : 0);
159 } 159 }
160 ~CFX_MemoryStream() 160 ~CFX_MemoryStream()
161 { 161 {
162 if (m_dwFlags & FX_MEMSTREAM_TakeOver) { 162 if (m_dwFlags & FX_MEMSTREAM_TakeOver) {
163 for (int32_t i = 0; i < m_Blocks.GetSize(); i++) { 163 for (int32_t i = 0; i < m_Blocks.GetSize(); i++) {
164 FX_Free((FX_LPBYTE)m_Blocks[i]); 164 FX_Free((uint8_t*)m_Blocks[i]);
165 } 165 }
166 } 166 }
167 m_Blocks.RemoveAll(); 167 m_Blocks.RemoveAll();
168 } 168 }
169 virtual IFX_FileStream* Retain() override 169 virtual IFX_FileStream* Retain() override
170 { 170 {
171 m_dwCount ++; 171 m_dwCount ++;
172 return this; 172 return this;
173 } 173 }
174 virtual void Release() override 174 virtual void Release() override
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 offset = safeOffset.ValueOrDie(); 233 offset = safeOffset.ValueOrDie();
234 234
235 FX_SAFE_SIZE_T newPos = size; 235 FX_SAFE_SIZE_T newPos = size;
236 newPos += offset; 236 newPos += offset;
237 if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 || newPos.ValueOr Die() > m_nCurSize) { 237 if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 || newPos.ValueOr Die() > m_nCurSize) {
238 return FALSE; 238 return FALSE;
239 } 239 }
240 240
241 m_nCurPos = newPos.ValueOrDie(); 241 m_nCurPos = newPos.ValueOrDie();
242 if (m_dwFlags & FX_MEMSTREAM_Consecutive) { 242 if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
243 FXSYS_memcpy32(buffer, (FX_LPBYTE)m_Blocks[0] + (size_t)offset, size ); 243 FXSYS_memcpy32(buffer, (uint8_t*)m_Blocks[0] + (size_t)offset, size) ;
244 return TRUE; 244 return TRUE;
245 } 245 }
246 size_t nStartBlock = (size_t)offset / m_nGrowSize; 246 size_t nStartBlock = (size_t)offset / m_nGrowSize;
247 offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize); 247 offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize);
248 while (size) { 248 while (size) {
249 size_t nRead = m_nGrowSize - (size_t)offset; 249 size_t nRead = m_nGrowSize - (size_t)offset;
250 if (nRead > size) { 250 if (nRead > size) {
251 nRead = size; 251 nRead = size;
252 } 252 }
253 FXSYS_memcpy32(buffer, (FX_LPBYTE)m_Blocks[(int)nStartBlock] + (size _t)offset, nRead); 253 FXSYS_memcpy32(buffer, (uint8_t*)m_Blocks[(int)nStartBlock] + (size_ t)offset, nRead);
254 buffer = ((FX_LPBYTE)buffer) + nRead; 254 buffer = ((uint8_t*)buffer) + nRead;
255 size -= nRead; 255 size -= nRead;
256 nStartBlock ++; 256 nStartBlock ++;
257 offset = 0; 257 offset = 0;
258 } 258 }
259 return TRUE; 259 return TRUE;
260 } 260 }
261 virtual size_t ReadBlock(void* buffer, size_t s ize) override 261 virtual size_t ReadBlock(void* buffer, size_t s ize) override
262 { 262 {
263 if (m_nCurPos >= m_nCurSize) { 263 if (m_nCurPos >= m_nCurSize) {
264 return 0; 264 return 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 void* block = FX_Alloc(uint8_t, m_nTotalSize); 296 void* block = FX_Alloc(uint8_t, m_nTotalSize);
297 m_Blocks.Add(block); 297 m_Blocks.Add(block);
298 } else { 298 } else {
299 m_Blocks[0] = FX_Realloc(uint8_t, m_Blocks[0], m_nTotalSize) ; 299 m_Blocks[0] = FX_Realloc(uint8_t, m_Blocks[0], m_nTotalSize) ;
300 } 300 }
301 if (!m_Blocks[0]) { 301 if (!m_Blocks[0]) {
302 m_Blocks.RemoveAll(); 302 m_Blocks.RemoveAll();
303 return FALSE; 303 return FALSE;
304 } 304 }
305 } 305 }
306 FXSYS_memcpy32((FX_LPBYTE)m_Blocks[0] + (size_t)offset, buffer, size ); 306 FXSYS_memcpy32((uint8_t*)m_Blocks[0] + (size_t)offset, buffer, size) ;
307 if (m_nCurSize < m_nCurPos) { 307 if (m_nCurSize < m_nCurPos) {
308 m_nCurSize = m_nCurPos; 308 m_nCurSize = m_nCurPos;
309 } 309 }
310 return TRUE; 310 return TRUE;
311 } 311 }
312 312
313 FX_SAFE_SIZE_T newPos = size; 313 FX_SAFE_SIZE_T newPos = size;
314 newPos += offset; 314 newPos += offset;
315 if (!newPos.IsValid()) { 315 if (!newPos.IsValid()) {
316 return FALSE; 316 return FALSE;
317 } 317 }
318 318
319 if (!ExpandBlocks(newPos.ValueOrDie())) { 319 if (!ExpandBlocks(newPos.ValueOrDie())) {
320 return FALSE; 320 return FALSE;
321 } 321 }
322 m_nCurPos = newPos.ValueOrDie(); 322 m_nCurPos = newPos.ValueOrDie();
323 size_t nStartBlock = (size_t)offset / m_nGrowSize; 323 size_t nStartBlock = (size_t)offset / m_nGrowSize;
324 offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize); 324 offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize);
325 while (size) { 325 while (size) {
326 size_t nWrite = m_nGrowSize - (size_t)offset; 326 size_t nWrite = m_nGrowSize - (size_t)offset;
327 if (nWrite > size) { 327 if (nWrite > size) {
328 nWrite = size; 328 nWrite = size;
329 } 329 }
330 FXSYS_memcpy32((FX_LPBYTE)m_Blocks[(int)nStartBlock] + (size_t)offse t, buffer, nWrite); 330 FXSYS_memcpy32((uint8_t*)m_Blocks[(int)nStartBlock] + (size_t)offset , buffer, nWrite);
331 buffer = ((FX_LPBYTE)buffer) + nWrite; 331 buffer = ((uint8_t*)buffer) + nWrite;
332 size -= nWrite; 332 size -= nWrite;
333 nStartBlock ++; 333 nStartBlock ++;
334 offset = 0; 334 offset = 0;
335 } 335 }
336 return TRUE; 336 return TRUE;
337 } 337 }
338 virtual FX_BOOL Flush() override 338 virtual FX_BOOL Flush() override
339 { 339 {
340 return TRUE; 340 return TRUE;
341 } 341 }
342 virtual FX_BOOL IsConsecutive() const override 342 virtual FX_BOOL IsConsecutive() const override
343 { 343 {
344 return m_dwFlags & FX_MEMSTREAM_Consecutive; 344 return m_dwFlags & FX_MEMSTREAM_Consecutive;
345 } 345 }
346 virtual void EstimateSize(size_t nInitSize, s ize_t nGrowSize) override 346 virtual void EstimateSize(size_t nInitSize, s ize_t nGrowSize) override
347 { 347 {
348 if (m_dwFlags & FX_MEMSTREAM_Consecutive) { 348 if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
349 if (m_Blocks.GetSize() < 1) { 349 if (m_Blocks.GetSize() < 1) {
350 FX_LPBYTE pBlock = FX_Alloc(uint8_t, FX_MAX(nInitSize, 4096)); 350 uint8_t* pBlock = FX_Alloc(uint8_t, FX_MAX(nInitSize, 4096));
351 m_Blocks.Add(pBlock); 351 m_Blocks.Add(pBlock);
352 } 352 }
353 m_nGrowSize = FX_MAX(nGrowSize, 4096); 353 m_nGrowSize = FX_MAX(nGrowSize, 4096);
354 } else if (m_Blocks.GetSize() < 1) { 354 } else if (m_Blocks.GetSize() < 1) {
355 m_nGrowSize = FX_MAX(nGrowSize, 4096); 355 m_nGrowSize = FX_MAX(nGrowSize, 4096);
356 } 356 }
357 } 357 }
358 virtual FX_LPBYTE» » » GetBuffer() const override 358 virtual uint8_t*» » » GetBuffer() const override
359 { 359 {
360 return m_Blocks.GetSize() ? (FX_LPBYTE)m_Blocks[0] : NULL; 360 return m_Blocks.GetSize() ? (uint8_t*)m_Blocks[0] : NULL;
361 } 361 }
362 virtual void» » » » AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE) override 362 virtual void» » » » AttachBuffer(uint8_t* pBuffer, s ize_t nSize, FX_BOOL bTakeOver = FALSE) override
363 { 363 {
364 if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) { 364 if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) {
365 return; 365 return;
366 } 366 }
367 m_Blocks.RemoveAll(); 367 m_Blocks.RemoveAll();
368 m_Blocks.Add(pBuffer); 368 m_Blocks.Add(pBuffer);
369 m_nTotalSize = m_nCurSize = nSize; 369 m_nTotalSize = m_nCurSize = nSize;
370 m_nCurPos = 0; 370 m_nCurPos = 0;
371 m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOve r : 0); 371 m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOve r : 0);
372 ClearRange(); 372 ClearRange();
(...skipping 24 matching lines...) Expand all
397 if (m_nCurSize < size) { 397 if (m_nCurSize < size) {
398 m_nCurSize = size; 398 m_nCurSize = size;
399 } 399 }
400 if (size <= m_nTotalSize) { 400 if (size <= m_nTotalSize) {
401 return TRUE; 401 return TRUE;
402 } 402 }
403 int32_t iCount = m_Blocks.GetSize(); 403 int32_t iCount = m_Blocks.GetSize();
404 size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize; 404 size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize;
405 m_Blocks.SetSize(m_Blocks.GetSize() + (int32_t)size); 405 m_Blocks.SetSize(m_Blocks.GetSize() + (int32_t)size);
406 while (size --) { 406 while (size --) {
407 FX_LPBYTE pBlock = FX_Alloc(uint8_t, m_nGrowSize); 407 uint8_t* pBlock = FX_Alloc(uint8_t, m_nGrowSize);
408 m_Blocks.SetAt(iCount ++, pBlock); 408 m_Blocks.SetAt(iCount ++, pBlock);
409 m_nTotalSize += m_nGrowSize; 409 m_nTotalSize += m_nGrowSize;
410 } 410 }
411 return TRUE; 411 return TRUE;
412 } 412 }
413 }; 413 };
414 #ifdef __cplusplus 414 #ifdef __cplusplus
415 extern "C" { 415 extern "C" {
416 #endif 416 #endif
417 #define MT_N 848 417 #define MT_N 848
418 #define MT_M 456 418 #define MT_M 456
419 #define MT_Matrix_A 0x9908b0df 419 #define MT_Matrix_A 0x9908b0df
420 #define MT_Upper_Mask 0x80000000 420 #define MT_Upper_Mask 0x80000000
421 #define MT_Lower_Mask 0x7fffffff 421 #define MT_Lower_Mask 0x7fffffff
422 typedef struct _FX_MTRANDOMCONTEXT { 422 typedef struct _FX_MTRANDOMCONTEXT {
423 _FX_MTRANDOMCONTEXT() 423 _FX_MTRANDOMCONTEXT()
424 { 424 {
425 mti = MT_N + 1; 425 mti = MT_N + 1;
426 bHaveSeed = FALSE; 426 bHaveSeed = FALSE;
427 } 427 }
428 FX_DWORD mti; 428 FX_DWORD mti;
429 FX_BOOL bHaveSeed; 429 FX_BOOL bHaveSeed;
430 FX_DWORD mt[MT_N]; 430 FX_DWORD mt[MT_N];
431 } FX_MTRANDOMCONTEXT, * FX_LPMTRANDOMCONTEXT; 431 } FX_MTRANDOMCONTEXT, * FX_LPMTRANDOMCONTEXT;
432 typedef FX_MTRANDOMCONTEXT const * FX_LPCMTRANDOMCONTEXT; 432 typedef FX_MTRANDOMCONTEXT const * FX_LPCMTRANDOMCONTEXT;
433 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 433 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
434 FX_BOOL FX_GenerateCryptoRandom(FX_LPDWORD pBuffer, int32_t iCount); 434 FX_BOOL FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount);
435 #endif 435 #endif
436 #ifdef __cplusplus 436 #ifdef __cplusplus
437 } 437 }
438 #endif 438 #endif
439 439
440 #endif // CORE_SRC_FXCRT_EXTENSION_H_ 440 #endif // CORE_SRC_FXCRT_EXTENSION_H_
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Segment.h ('k') | core/src/fxcrt/fx_basic_array.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698