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

Side by Side Diff: xfa/fgas/crt/fgas_utils.h

Issue 2095653002: Remove NULL in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 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 | « xfa/fgas/crt/fgas_system.cpp ('k') | xfa/fgas/crt/fgas_utils.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 XFA_FGAS_CRT_FGAS_UTILS_H_ 7 #ifndef XFA_FGAS_CRT_FGAS_UTILS_H_
8 #define XFA_FGAS_CRT_FGAS_UTILS_H_ 8 #define XFA_FGAS_CRT_FGAS_UTILS_H_
9 9
10 #include "core/fxcrt/include/fx_coordinates.h" 10 #include "core/fxcrt/include/fx_coordinates.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 void* m_pData; 371 void* m_pData;
372 }; 372 };
373 373
374 template <class baseType> 374 template <class baseType>
375 class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray { 375 class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray {
376 public: 376 public:
377 CFX_DiscreteArrayTemplate(int32_t iChunkSize = 100) 377 CFX_DiscreteArrayTemplate(int32_t iChunkSize = 100)
378 : CFX_BaseDiscreteArray(iChunkSize, sizeof(baseType)) {} 378 : CFX_BaseDiscreteArray(iChunkSize, sizeof(baseType)) {}
379 baseType& GetAt(int32_t index, const baseType& defValue) const { 379 baseType& GetAt(int32_t index, const baseType& defValue) const {
380 baseType* p = (baseType*)CFX_BaseDiscreteArray::GetAt(index); 380 baseType* p = (baseType*)CFX_BaseDiscreteArray::GetAt(index);
381 return p == NULL ? (baseType&)defValue : *p; 381 return p ? *p : (baseType&)defValue;
382 } 382 }
383 baseType* GetPtrAt(int32_t index) const { 383 baseType* GetPtrAt(int32_t index) const {
384 return (baseType*)CFX_BaseDiscreteArray::GetAt(index); 384 return (baseType*)CFX_BaseDiscreteArray::GetAt(index);
385 } 385 }
386 void SetAtGrow(int32_t index, const baseType& element) { 386 void SetAtGrow(int32_t index, const baseType& element) {
387 *(baseType*)CFX_BaseDiscreteArray::AddSpaceTo(index) = element; 387 *(baseType*)CFX_BaseDiscreteArray::AddSpaceTo(index) = element;
388 } 388 }
389 void RemoveAll() { CFX_BaseDiscreteArray::RemoveAll(); } 389 void RemoveAll() { CFX_BaseDiscreteArray::RemoveAll(); }
390 }; 390 };
391 typedef CFX_DiscreteArrayTemplate<void*> CFX_PtrDiscreteArray; 391 typedef CFX_DiscreteArrayTemplate<void*> CFX_PtrDiscreteArray;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 : CFX_BaseStack(iChunkSize, sizeof(baseType)) {} 440 : CFX_BaseStack(iChunkSize, sizeof(baseType)) {}
441 ~CFX_ObjectStackTemplate() { RemoveAll(); } 441 ~CFX_ObjectStackTemplate() { RemoveAll(); }
442 int32_t Push(const baseType& element) { 442 int32_t Push(const baseType& element) {
443 int32_t index = CFX_BaseStack::GetSize(); 443 int32_t index = CFX_BaseStack::GetSize();
444 baseType* p = (baseType*)CFX_BaseStack::Push(); 444 baseType* p = (baseType*)CFX_BaseStack::Push();
445 new ((void*)p) baseType(element); 445 new ((void*)p) baseType(element);
446 return index; 446 return index;
447 } 447 }
448 void Pop() { 448 void Pop() {
449 baseType* p = (baseType*)CFX_BaseStack::GetTopElement(); 449 baseType* p = (baseType*)CFX_BaseStack::GetTopElement();
450 if (p != NULL) { 450 if (p) {
451 p->~baseType(); 451 p->~baseType();
452 } 452 }
453 CFX_BaseStack::Pop(); 453 CFX_BaseStack::Pop();
454 } 454 }
455 baseType* GetTopElement() const { 455 baseType* GetTopElement() const {
456 return (baseType*)CFX_BaseStack::GetTopElement(); 456 return (baseType*)CFX_BaseStack::GetTopElement();
457 } 457 }
458 int32_t GetSize() const { return CFX_BaseStack::GetSize(); } 458 int32_t GetSize() const { return CFX_BaseStack::GetSize(); }
459 baseType* GetAt(int32_t index) const { 459 baseType* GetAt(int32_t index) const {
460 return (baseType*)CFX_BaseStack::GetAt(index); 460 return (baseType*)CFX_BaseStack::GetAt(index);
(...skipping 22 matching lines...) Expand all
483 } 483 }
484 RemoveAll(TRUE); 484 RemoveAll(TRUE);
485 for (int32_t i = iStart; i < iEnd; i++) { 485 for (int32_t i = iStart; i < iEnd; i++) {
486 Push(*src.GetAt(i)); 486 Push(*src.GetAt(i));
487 } 487 }
488 return CFX_BaseStack::GetSize(); 488 return CFX_BaseStack::GetSize();
489 } 489 }
490 }; 490 };
491 491
492 #endif // XFA_FGAS_CRT_FGAS_UTILS_H_ 492 #endif // XFA_FGAS_CRT_FGAS_UTILS_H_
OLDNEW
« no previous file with comments | « xfa/fgas/crt/fgas_system.cpp ('k') | xfa/fgas/crt/fgas_utils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698