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

Side by Side Diff: core/fxcrt/fx_basic_list.cpp

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix a bad merge 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 | « core/fxcrt/fx_basic_gcc.cpp ('k') | core/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/fxcrt/include/fx_basic.h" 7 #include "core/fxcrt/include/fx_basic.h"
8 #include "core/fxcrt/plex.h" 8 #include "core/fxcrt/plex.h"
9 9
10 CFX_PtrList::CFX_PtrList(int nBlockSize) 10 CFX_PtrList::CFX_PtrList(int nBlockSize)
11 : m_pNodeHead(NULL), 11 : m_pNodeHead(nullptr),
12 m_pNodeTail(NULL), 12 m_pNodeTail(nullptr),
13 m_nCount(0), 13 m_nCount(0),
14 m_pNodeFree(NULL), 14 m_pNodeFree(nullptr),
15 m_pBlocks(NULL), 15 m_pBlocks(nullptr),
16 m_nBlockSize(nBlockSize) {} 16 m_nBlockSize(nBlockSize) {}
17 FX_POSITION CFX_PtrList::AddTail(void* newElement) { 17 FX_POSITION CFX_PtrList::AddTail(void* newElement) {
18 CNode* pNewNode = NewNode(m_pNodeTail, NULL); 18 CNode* pNewNode = NewNode(m_pNodeTail, nullptr);
19 pNewNode->data = newElement; 19 pNewNode->data = newElement;
20 if (m_pNodeTail) { 20 if (m_pNodeTail) {
21 m_pNodeTail->pNext = pNewNode; 21 m_pNodeTail->pNext = pNewNode;
22 } else { 22 } else {
23 m_pNodeHead = pNewNode; 23 m_pNodeHead = pNewNode;
24 } 24 }
25 m_pNodeTail = pNewNode; 25 m_pNodeTail = pNewNode;
26 return (FX_POSITION)pNewNode; 26 return (FX_POSITION)pNewNode;
27 } 27 }
28 FX_POSITION CFX_PtrList::AddHead(void* newElement) { 28 FX_POSITION CFX_PtrList::AddHead(void* newElement) {
29 CNode* pNewNode = NewNode(NULL, m_pNodeHead); 29 CNode* pNewNode = NewNode(nullptr, m_pNodeHead);
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) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ASSERT(m_nCount > 0); 105 ASSERT(m_nCount > 0);
106 pNode->data = 0; 106 pNode->data = 0;
107 return pNode; 107 return pNode;
108 } 108 }
109 CFX_PtrList::~CFX_PtrList() { 109 CFX_PtrList::~CFX_PtrList() {
110 RemoveAll(); 110 RemoveAll();
111 ASSERT(m_nCount == 0); 111 ASSERT(m_nCount == 0);
112 } 112 }
113 FX_POSITION CFX_PtrList::FindIndex(int nIndex) const { 113 FX_POSITION CFX_PtrList::FindIndex(int nIndex) const {
114 if (nIndex >= m_nCount || nIndex < 0) { 114 if (nIndex >= m_nCount || nIndex < 0) {
115 return NULL; 115 return nullptr;
116 } 116 }
117 CNode* pNode = m_pNodeHead; 117 CNode* pNode = m_pNodeHead;
118 while (nIndex--) { 118 while (nIndex--) {
119 pNode = pNode->pNext; 119 pNode = pNode->pNext;
120 } 120 }
121 return (FX_POSITION)pNode; 121 return (FX_POSITION)pNode;
122 } 122 }
123 FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const { 123 FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const {
124 CNode* pNode = (CNode*)startAfter; 124 CNode* pNode = (CNode*)startAfter;
125 pNode = pNode ? pNode->pNext : m_pNodeHead; 125 pNode = pNode ? pNode->pNext : m_pNodeHead;
126 for (; pNode; pNode = pNode->pNext) { 126 for (; pNode; pNode = pNode->pNext) {
127 if (pNode->data == searchValue) 127 if (pNode->data == searchValue)
128 return (FX_POSITION)pNode; 128 return (FX_POSITION)pNode;
129 } 129 }
130 return NULL; 130 return nullptr;
131 } 131 }
OLDNEW
« no previous file with comments | « core/fxcrt/fx_basic_gcc.cpp ('k') | core/fxcrt/fx_basic_maps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698