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

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

Issue 372473003: Remove custom memory manager (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Change malloc to calloc Created 6 years, 5 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/src/fxcrt/fx_basic_buffer.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 "../../include/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 #include "plex.h" 8 #include "plex.h"
9 CFX_PtrList::CFX_PtrList(int nBlockSize, IFX_Allocator* pAllocator) 9 CFX_PtrList::CFX_PtrList(int nBlockSize)
10 : m_pAllocator(pAllocator) 10 : m_pNodeHead(NULL)
11 , m_pNodeHead(NULL)
12 , m_pNodeTail(NULL) 11 , m_pNodeTail(NULL)
13 , m_nCount(0) 12 , m_nCount(0)
14 , m_pNodeFree(NULL) 13 , m_pNodeFree(NULL)
15 , m_pBlocks(NULL) 14 , m_pBlocks(NULL)
16 , m_nBlockSize(nBlockSize) 15 , m_nBlockSize(nBlockSize)
17 { 16 {
18 } 17 }
19 FX_POSITION CFX_PtrList::AddTail(void* newElement) 18 FX_POSITION CFX_PtrList::AddTail(void* newElement)
20 { 19 {
21 CNode* pNewNode = NewNode(m_pNodeTail, NULL); 20 CNode* pNewNode = NewNode(m_pNodeTail, NULL);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 m_pNodeFree = pNode; 76 m_pNodeFree = pNode;
78 m_nCount--; 77 m_nCount--;
79 if (m_nCount == 0) { 78 if (m_nCount == 0) {
80 RemoveAll(); 79 RemoveAll();
81 } 80 }
82 } 81 }
83 void CFX_PtrList::RemoveAll() 82 void CFX_PtrList::RemoveAll()
84 { 83 {
85 m_nCount = 0; 84 m_nCount = 0;
86 m_pNodeHead = m_pNodeTail = m_pNodeFree = NULL; 85 m_pNodeHead = m_pNodeTail = m_pNodeFree = NULL;
87 m_pBlocks->FreeDataChain(m_pAllocator); 86 m_pBlocks->FreeDataChain();
88 m_pBlocks = NULL; 87 m_pBlocks = NULL;
89 } 88 }
90 CFX_PtrList::CNode* 89 CFX_PtrList::CNode*
91 CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev, CFX_PtrList::CNode* pNext) 90 CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev, CFX_PtrList::CNode* pNext)
92 { 91 {
93 if (m_pNodeFree == NULL) { 92 if (m_pNodeFree == NULL) {
94 CFX_Plex* pNewBlock = CFX_Plex::Create(m_pAllocator, m_pBlocks, m_nBlock Size, sizeof(CNode)); 93 CFX_Plex* pNewBlock = CFX_Plex::Create(m_pBlocks, m_nBlockSize, sizeof(C Node));
95 CNode* pNode = (CNode*)pNewBlock->data(); 94 CNode* pNode = (CNode*)pNewBlock->data();
96 pNode += m_nBlockSize - 1; 95 pNode += m_nBlockSize - 1;
97 for (int i = m_nBlockSize - 1; i >= 0; i--, pNode--) { 96 for (int i = m_nBlockSize - 1; i >= 0; i--, pNode--) {
98 pNode->pNext = m_pNodeFree; 97 pNode->pNext = m_pNodeFree;
99 m_pNodeFree = pNode; 98 m_pNodeFree = pNode;
100 } 99 }
101 } 100 }
102 ASSERT(m_pNodeFree != NULL); 101 ASSERT(m_pNodeFree != NULL);
103 CFX_PtrList::CNode* pNode = m_pNodeFree; 102 CFX_PtrList::CNode* pNode = m_pNodeFree;
104 m_pNodeFree = m_pNodeFree->pNext; 103 m_pNodeFree = m_pNodeFree->pNext;
(...skipping 27 matching lines...) Expand all
132 pNode = m_pNodeHead; 131 pNode = m_pNodeHead;
133 } else { 132 } else {
134 pNode = pNode->pNext; 133 pNode = pNode->pNext;
135 } 134 }
136 for (; pNode != NULL; pNode = pNode->pNext) 135 for (; pNode != NULL; pNode = pNode->pNext)
137 if (pNode->data == searchValue) { 136 if (pNode->data == searchValue) {
138 return (FX_POSITION) pNode; 137 return (FX_POSITION) pNode;
139 } 138 }
140 return NULL; 139 return NULL;
141 } 140 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_buffer.cpp ('k') | core/src/fxcrt/fx_basic_maps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698