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

Side by Side Diff: core/src/fxcrt/fx_basic_list.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
« no previous file with comments | « core/src/fxcrt/fx_basic_gcc.cpp ('k') | core/src/fxcrt/fx_basic_maps.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 #include "core/include/fxcrt/fx_basic.h" 7 #include "core/include/fxcrt/fx_basic.h"
8 #include "plex.h" 8 #include "plex.h"
9 9
10 CFX_PtrList::CFX_PtrList(int nBlockSize) 10 CFX_PtrList::CFX_PtrList(int nBlockSize)
(...skipping 19 matching lines...) Expand all
30 pNewNode->data = newElement; 30 pNewNode->data = newElement;
31 if (m_pNodeHead) { 31 if (m_pNodeHead) {
32 m_pNodeHead->pPrev = pNewNode; 32 m_pNodeHead->pPrev = pNewNode;
33 } else { 33 } else {
34 m_pNodeTail = pNewNode; 34 m_pNodeTail = pNewNode;
35 } 35 }
36 m_pNodeHead = pNewNode; 36 m_pNodeHead = pNewNode;
37 return (FX_POSITION)pNewNode; 37 return (FX_POSITION)pNewNode;
38 } 38 }
39 FX_POSITION CFX_PtrList::InsertAfter(FX_POSITION position, void* newElement) { 39 FX_POSITION CFX_PtrList::InsertAfter(FX_POSITION position, void* newElement) {
40 if (position == NULL) { 40 if (!position) {
41 return AddTail(newElement); 41 return AddTail(newElement);
42 } 42 }
43 CNode* pOldNode = (CNode*)position; 43 CNode* pOldNode = (CNode*)position;
44 CNode* pNewNode = NewNode(pOldNode, pOldNode->pNext); 44 CNode* pNewNode = NewNode(pOldNode, pOldNode->pNext);
45 pNewNode->data = newElement; 45 pNewNode->data = newElement;
46 if (pOldNode->pNext) { 46 if (pOldNode->pNext) {
47 pOldNode->pNext->pPrev = pNewNode; 47 pOldNode->pNext->pPrev = pNewNode;
48 } else { 48 } else {
49 m_pNodeTail = pNewNode; 49 m_pNodeTail = pNewNode;
50 } 50 }
(...skipping 23 matching lines...) Expand all
74 } 74 }
75 } 75 }
76 void CFX_PtrList::RemoveAll() { 76 void CFX_PtrList::RemoveAll() {
77 m_nCount = 0; 77 m_nCount = 0;
78 m_pNodeHead = m_pNodeTail = m_pNodeFree = NULL; 78 m_pNodeHead = m_pNodeTail = m_pNodeFree = NULL;
79 m_pBlocks->FreeDataChain(); 79 m_pBlocks->FreeDataChain();
80 m_pBlocks = NULL; 80 m_pBlocks = NULL;
81 } 81 }
82 CFX_PtrList::CNode* CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev, 82 CFX_PtrList::CNode* CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev,
83 CFX_PtrList::CNode* pNext) { 83 CFX_PtrList::CNode* pNext) {
84 if (m_pNodeFree == NULL) { 84 if (!m_pNodeFree) {
85 CFX_Plex* pNewBlock = 85 CFX_Plex* pNewBlock =
86 CFX_Plex::Create(m_pBlocks, m_nBlockSize, sizeof(CNode)); 86 CFX_Plex::Create(m_pBlocks, m_nBlockSize, sizeof(CNode));
87 CNode* pNode = (CNode*)pNewBlock->data(); 87 CNode* pNode = (CNode*)pNewBlock->data();
88 pNode += m_nBlockSize - 1; 88 pNode += m_nBlockSize - 1;
89 for (int i = m_nBlockSize - 1; i >= 0; i--, pNode--) { 89 for (int i = m_nBlockSize - 1; i >= 0; i--, pNode--) {
90 pNode->pNext = m_pNodeFree; 90 pNode->pNext = m_pNodeFree;
91 m_pNodeFree = pNode; 91 m_pNodeFree = pNode;
92 } 92 }
93 } 93 }
94 CFX_PtrList::CNode* pNode = m_pNodeFree; 94 CFX_PtrList::CNode* pNode = m_pNodeFree;
(...skipping 14 matching lines...) Expand all
109 return NULL; 109 return NULL;
110 } 110 }
111 CNode* pNode = m_pNodeHead; 111 CNode* pNode = m_pNodeHead;
112 while (nIndex--) { 112 while (nIndex--) {
113 pNode = pNode->pNext; 113 pNode = pNode->pNext;
114 } 114 }
115 return (FX_POSITION)pNode; 115 return (FX_POSITION)pNode;
116 } 116 }
117 FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const { 117 FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const {
118 CNode* pNode = (CNode*)startAfter; 118 CNode* pNode = (CNode*)startAfter;
119 if (pNode == NULL) { 119 pNode = pNode ? pNode->pNext : m_pNodeHead;
120 pNode = m_pNodeHead;
121 } else {
122 pNode = pNode->pNext;
123 }
124 for (; pNode; pNode = pNode->pNext) { 120 for (; pNode; pNode = pNode->pNext) {
125 if (pNode->data == searchValue) 121 if (pNode->data == searchValue)
126 return (FX_POSITION)pNode; 122 return (FX_POSITION)pNode;
127 } 123 }
128 return NULL; 124 return NULL;
129 } 125 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_gcc.cpp ('k') | core/src/fxcrt/fx_basic_maps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698