Chromium Code Reviews| OLD | NEW |
|---|---|
| 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) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 void CFX_PtrList::FreeNode(CFX_PtrList::CNode* pNode) { | 68 void CFX_PtrList::FreeNode(CFX_PtrList::CNode* pNode) { |
| 69 pNode->pNext = m_pNodeFree; | 69 pNode->pNext = m_pNodeFree; |
| 70 m_pNodeFree = pNode; | 70 m_pNodeFree = pNode; |
| 71 m_nCount--; | 71 m_nCount--; |
| 72 if (m_nCount == 0) { | 72 if (m_nCount == 0) { |
| 73 RemoveAll(); | 73 RemoveAll(); |
| 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; |
|
Tom Sepez
2016/05/19 17:02:01
nit: one per pline.
Lei Zhang
2016/05/19 20:48:50
Done.
| |
| 79 m_pBlocks->FreeDataChain(); | 79 if (m_pBlocks) |
|
Tom Sepez
2016/05/19 17:02:01
Ah, idempotency.
Nit: As long as we're going to t
Lei Zhang
2016/05/19 20:48:50
Done.
| |
| 80 m_pBlocks->FreeDataChain(); | |
| 80 m_pBlocks = NULL; | 81 m_pBlocks = NULL; |
|
Tom Sepez
2016/05/19 17:02:01
nit: nullptr, also above.
Lei Zhang
2016/05/19 20:48:50
Done.
| |
| 81 } | 82 } |
| 82 CFX_PtrList::CNode* CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev, | 83 CFX_PtrList::CNode* CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev, |
| 83 CFX_PtrList::CNode* pNext) { | 84 CFX_PtrList::CNode* pNext) { |
| 84 if (!m_pNodeFree) { | 85 if (!m_pNodeFree) { |
| 85 CFX_Plex* pNewBlock = | 86 CFX_Plex* pNewBlock = |
| 86 CFX_Plex::Create(m_pBlocks, m_nBlockSize, sizeof(CNode)); | 87 CFX_Plex::Create(m_pBlocks, m_nBlockSize, sizeof(CNode)); |
| 87 CNode* pNode = (CNode*)pNewBlock->data(); | 88 CNode* pNode = (CNode*)pNewBlock->data(); |
| 88 pNode += m_nBlockSize - 1; | 89 pNode += m_nBlockSize - 1; |
| 89 for (int i = m_nBlockSize - 1; i >= 0; i--, pNode--) { | 90 for (int i = m_nBlockSize - 1; i >= 0; i--, pNode--) { |
| 90 pNode->pNext = m_pNodeFree; | 91 pNode->pNext = m_pNodeFree; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 116 } | 117 } |
| 117 FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const { | 118 FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const { |
| 118 CNode* pNode = (CNode*)startAfter; | 119 CNode* pNode = (CNode*)startAfter; |
| 119 pNode = pNode ? pNode->pNext : m_pNodeHead; | 120 pNode = pNode ? pNode->pNext : m_pNodeHead; |
| 120 for (; pNode; pNode = pNode->pNext) { | 121 for (; pNode; pNode = pNode->pNext) { |
| 121 if (pNode->data == searchValue) | 122 if (pNode->data == searchValue) |
| 122 return (FX_POSITION)pNode; | 123 return (FX_POSITION)pNode; |
| 123 } | 124 } |
| 124 return NULL; | 125 return NULL; |
| 125 } | 126 } |
| OLD | NEW |