summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_basic.h72
-rw-r--r--core/fxcrt/fx_basic_list.cpp131
2 files changed, 0 insertions, 203 deletions
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index 7096e6f8df..3b09489d71 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -433,79 +433,7 @@ class CFX_MapPtrTemplate : public CFX_MapPtrToPtr {
rValue = (ValueType)(uintptr_t)pValue;
}
};
-#endif // PDF_ENABLE_XFA
-
-class CFX_PtrList {
- protected:
- struct CNode {
- CNode* pNext;
- CNode* pPrev;
- void* data;
- };
-
- public:
- explicit CFX_PtrList(int nBlockSize = 10);
-
- FX_POSITION GetHeadPosition() const { return (FX_POSITION)m_pNodeHead; }
- FX_POSITION GetTailPosition() const { return (FX_POSITION)m_pNodeTail; }
-
- void* GetNext(FX_POSITION& rPosition) const {
- CNode* pNode = (CNode*)rPosition;
- rPosition = (FX_POSITION)pNode->pNext;
- return pNode->data;
- }
-
- void* GetPrev(FX_POSITION& rPosition) const {
- CNode* pNode = (CNode*)rPosition;
- rPosition = (FX_POSITION)pNode->pPrev;
- return pNode->data;
- }
-
- FX_POSITION GetNextPosition(FX_POSITION pos) const {
- return ((CNode*)pos)->pNext;
- }
-
- FX_POSITION GetPrevPosition(FX_POSITION pos) const {
- return ((CNode*)pos)->pPrev;
- }
-
- void* GetAt(FX_POSITION rPosition) const {
- CNode* pNode = (CNode*)rPosition;
- return pNode->data;
- }
- int GetCount() const { return m_nCount; }
- FX_POSITION AddTail(void* newElement);
- FX_POSITION AddHead(void* newElement);
-
- void SetAt(FX_POSITION pos, void* newElement) {
- CNode* pNode = (CNode*)pos;
- pNode->data = newElement;
- }
- FX_POSITION InsertAfter(FX_POSITION pos, void* newElement);
-
- FX_POSITION Find(void* searchValue, FX_POSITION startAfter = nullptr) const;
- FX_POSITION FindIndex(int index) const;
-
- void RemoveAt(FX_POSITION pos);
- void RemoveAll();
-
- protected:
- CNode* m_pNodeHead;
- CNode* m_pNodeTail;
- int m_nCount;
- CNode* m_pNodeFree;
- struct CFX_Plex* m_pBlocks;
- int m_nBlockSize;
-
- CNode* NewNode(CNode* pPrev, CNode* pNext);
- void FreeNode(CNode* pNode);
-
- public:
- ~CFX_PtrList();
-};
-
-#ifdef PDF_ENABLE_XFA
typedef void (*PD_CALLBACK_FREEDATA)(void* pData);
#endif // PDF_ENABLE_XFA
diff --git a/core/fxcrt/fx_basic_list.cpp b/core/fxcrt/fx_basic_list.cpp
deleted file mode 100644
index 09ad08b281..0000000000
--- a/core/fxcrt/fx_basic_list.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/fxcrt/fx_basic.h"
-#include "core/fxcrt/plex.h"
-
-CFX_PtrList::CFX_PtrList(int nBlockSize)
- : m_pNodeHead(nullptr),
- m_pNodeTail(nullptr),
- m_nCount(0),
- m_pNodeFree(nullptr),
- m_pBlocks(nullptr),
- m_nBlockSize(nBlockSize) {}
-FX_POSITION CFX_PtrList::AddTail(void* newElement) {
- CNode* pNewNode = NewNode(m_pNodeTail, nullptr);
- pNewNode->data = newElement;
- if (m_pNodeTail) {
- m_pNodeTail->pNext = pNewNode;
- } else {
- m_pNodeHead = pNewNode;
- }
- m_pNodeTail = pNewNode;
- return (FX_POSITION)pNewNode;
-}
-FX_POSITION CFX_PtrList::AddHead(void* newElement) {
- CNode* pNewNode = NewNode(nullptr, m_pNodeHead);
- pNewNode->data = newElement;
- if (m_pNodeHead) {
- m_pNodeHead->pPrev = pNewNode;
- } else {
- m_pNodeTail = pNewNode;
- }
- m_pNodeHead = pNewNode;
- return (FX_POSITION)pNewNode;
-}
-FX_POSITION CFX_PtrList::InsertAfter(FX_POSITION position, void* newElement) {
- if (!position) {
- return AddTail(newElement);
- }
- CNode* pOldNode = (CNode*)position;
- CNode* pNewNode = NewNode(pOldNode, pOldNode->pNext);
- pNewNode->data = newElement;
- if (pOldNode->pNext) {
- pOldNode->pNext->pPrev = pNewNode;
- } else {
- m_pNodeTail = pNewNode;
- }
- pOldNode->pNext = pNewNode;
- return (FX_POSITION)pNewNode;
-}
-void CFX_PtrList::RemoveAt(FX_POSITION position) {
- CNode* pOldNode = (CNode*)position;
- if (pOldNode == m_pNodeHead) {
- m_pNodeHead = pOldNode->pNext;
- } else {
- pOldNode->pPrev->pNext = pOldNode->pNext;
- }
- if (pOldNode == m_pNodeTail) {
- m_pNodeTail = pOldNode->pPrev;
- } else {
- pOldNode->pNext->pPrev = pOldNode->pPrev;
- }
- FreeNode(pOldNode);
-}
-void CFX_PtrList::FreeNode(CFX_PtrList::CNode* pNode) {
- pNode->pNext = m_pNodeFree;
- m_pNodeFree = pNode;
- m_nCount--;
- if (m_nCount == 0) {
- RemoveAll();
- }
-}
-
-void CFX_PtrList::RemoveAll() {
- m_nCount = 0;
- m_pNodeHead = nullptr;
- m_pNodeTail = nullptr;
- m_pNodeFree = nullptr;
- if (m_pBlocks) {
- m_pBlocks->FreeDataChain();
- m_pBlocks = nullptr;
- }
-}
-
-CFX_PtrList::CNode* CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev,
- CFX_PtrList::CNode* pNext) {
- if (!m_pNodeFree) {
- CFX_Plex* pNewBlock =
- CFX_Plex::Create(m_pBlocks, m_nBlockSize, sizeof(CNode));
- CNode* pNode = (CNode*)pNewBlock->data();
- pNode += m_nBlockSize - 1;
- for (int i = m_nBlockSize - 1; i >= 0; i--, pNode--) {
- pNode->pNext = m_pNodeFree;
- m_pNodeFree = pNode;
- }
- }
- CFX_PtrList::CNode* pNode = m_pNodeFree;
- m_pNodeFree = m_pNodeFree->pNext;
- pNode->pPrev = pPrev;
- pNode->pNext = pNext;
- m_nCount++;
- ASSERT(m_nCount > 0);
- pNode->data = 0;
- return pNode;
-}
-CFX_PtrList::~CFX_PtrList() {
- RemoveAll();
- ASSERT(m_nCount == 0);
-}
-FX_POSITION CFX_PtrList::FindIndex(int nIndex) const {
- if (nIndex >= m_nCount || nIndex < 0) {
- return nullptr;
- }
- CNode* pNode = m_pNodeHead;
- while (nIndex--) {
- pNode = pNode->pNext;
- }
- return (FX_POSITION)pNode;
-}
-FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const {
- CNode* pNode = (CNode*)startAfter;
- pNode = pNode ? pNode->pNext : m_pNodeHead;
- for (; pNode; pNode = pNode->pNext) {
- if (pNode->data == searchValue)
- return (FX_POSITION)pNode;
- }
- return nullptr;
-}