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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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
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 "core/include/fpdfapi/fpdf_parser.h" 7 #include "core/include/fpdfapi/fpdf_parser.h"
8 8
9 #include "core/include/fxcrt/fx_string.h" 9 #include "core/include/fxcrt/fx_string.h"
10 10
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 while (pos) { 575 while (pos) {
576 if (CPDF_Object* value = static_cast<CPDF_Object*>(m_Map.GetNextValue(pos))) 576 if (CPDF_Object* value = static_cast<CPDF_Object*>(m_Map.GetNextValue(pos)))
577 value->Release(); 577 value->Release();
578 } 578 }
579 } 579 }
580 FX_POSITION CPDF_Dictionary::GetStartPos() const { 580 FX_POSITION CPDF_Dictionary::GetStartPos() const {
581 return m_Map.GetStartPosition(); 581 return m_Map.GetStartPosition();
582 } 582 }
583 CPDF_Object* CPDF_Dictionary::GetNextElement(FX_POSITION& pos, 583 CPDF_Object* CPDF_Dictionary::GetNextElement(FX_POSITION& pos,
584 CFX_ByteString& key) const { 584 CFX_ByteString& key) const {
585 if (pos == NULL) { 585 if (!pos) {
586 return NULL; 586 return NULL;
587 } 587 }
588 CPDF_Object* p; 588 CPDF_Object* p;
589 m_Map.GetNextAssoc(pos, key, (void*&)p); 589 m_Map.GetNextAssoc(pos, key, (void*&)p);
590 return p; 590 return p;
591 } 591 }
592 CPDF_Object* CPDF_Dictionary::GetElement(const CFX_ByteStringC& key) const { 592 CPDF_Object* CPDF_Dictionary::GetElement(const CFX_ByteStringC& key) const {
593 CPDF_Object* p = NULL; 593 CPDF_Object* p = NULL;
594 m_Map.Lookup(key, (void*&)p); 594 m_Map.Lookup(key, (void*&)p);
595 return p; 595 return p;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 } 729 }
730 730
731 void CPDF_Dictionary::AddValue(const CFX_ByteStringC& key, CPDF_Object* pObj) { 731 void CPDF_Dictionary::AddValue(const CFX_ByteStringC& key, CPDF_Object* pObj) {
732 ASSERT(m_Type == PDFOBJ_DICTIONARY); 732 ASSERT(m_Type == PDFOBJ_DICTIONARY);
733 m_Map.AddValue(key, pObj); 733 m_Map.AddValue(key, pObj);
734 } 734 }
735 void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) { 735 void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) {
736 ASSERT(m_Type == PDFOBJ_DICTIONARY); 736 ASSERT(m_Type == PDFOBJ_DICTIONARY);
737 CPDF_Object* p = NULL; 737 CPDF_Object* p = NULL;
738 m_Map.Lookup(key, (void*&)p); 738 m_Map.Lookup(key, (void*&)p);
739 if (p == NULL) { 739 if (!p) {
740 return; 740 return;
741 } 741 }
742 p->Release(); 742 p->Release();
743 m_Map.RemoveKey(key); 743 m_Map.RemoveKey(key);
744 } 744 }
745 void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey, 745 void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey,
746 const CFX_ByteStringC& newkey) { 746 const CFX_ByteStringC& newkey) {
747 ASSERT(m_Type == PDFOBJ_DICTIONARY); 747 ASSERT(m_Type == PDFOBJ_DICTIONARY);
748 CPDF_Object* p = NULL; 748 CPDF_Object* p = NULL;
749 m_Map.Lookup(oldkey, (void*&)p); 749 m_Map.Lookup(oldkey, (void*&)p);
750 if (p == NULL) { 750 if (!p) {
751 return; 751 return;
752 } 752 }
753 m_Map.RemoveKey(oldkey); 753 m_Map.RemoveKey(oldkey);
754 m_Map.SetAt(newkey, p); 754 m_Map.SetAt(newkey, p);
755 } 755 }
756 FX_BOOL CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const { 756 FX_BOOL CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const {
757 if (pOther == NULL) { 757 if (!pOther) {
758 return FALSE; 758 return FALSE;
759 } 759 }
760 if (m_Map.GetCount() != pOther->m_Map.GetCount()) { 760 if (m_Map.GetCount() != pOther->m_Map.GetCount()) {
761 return FALSE; 761 return FALSE;
762 } 762 }
763 FX_POSITION pos = m_Map.GetStartPosition(); 763 FX_POSITION pos = m_Map.GetStartPosition();
764 while (pos) { 764 while (pos) {
765 CFX_ByteString key; 765 CFX_ByteString key;
766 void* value; 766 void* value;
767 m_Map.GetNextAssoc(pos, key, value); 767 m_Map.GetNextAssoc(pos, key, value);
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 } 1170 }
1171 pObj->m_ObjNum = objnum; 1171 pObj->m_ObjNum = objnum;
1172 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); 1172 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj);
1173 if (m_LastObjNum < objnum) 1173 if (m_LastObjNum < objnum)
1174 m_LastObjNum = objnum; 1174 m_LastObjNum = objnum;
1175 return TRUE; 1175 return TRUE;
1176 } 1176 }
1177 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { 1177 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const {
1178 return m_LastObjNum; 1178 return m_LastObjNum;
1179 } 1179 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698