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

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

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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_plex.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_MapPtrToPtr::CFX_MapPtrToPtr(int nBlockSize) 10 CFX_MapPtrToPtr::CFX_MapPtrToPtr(int nBlockSize)
(...skipping 10 matching lines...) Expand all
21 m_pHashTable = NULL; 21 m_pHashTable = NULL;
22 m_nCount = 0; 22 m_nCount = 0;
23 m_pFreeList = NULL; 23 m_pFreeList = NULL;
24 m_pBlocks->FreeDataChain(); 24 m_pBlocks->FreeDataChain();
25 m_pBlocks = NULL; 25 m_pBlocks = NULL;
26 } 26 }
27 CFX_MapPtrToPtr::~CFX_MapPtrToPtr() { 27 CFX_MapPtrToPtr::~CFX_MapPtrToPtr() {
28 RemoveAll(); 28 RemoveAll();
29 ASSERT(m_nCount == 0); 29 ASSERT(m_nCount == 0);
30 } 30 }
31 FX_DWORD CFX_MapPtrToPtr::HashKey(void* key) const { 31 uint32_t CFX_MapPtrToPtr::HashKey(void* key) const {
32 return ((FX_DWORD)(uintptr_t)key) >> 4; 32 return ((uint32_t)(uintptr_t)key) >> 4;
33 } 33 }
34 void CFX_MapPtrToPtr::GetNextAssoc(FX_POSITION& rNextPosition, 34 void CFX_MapPtrToPtr::GetNextAssoc(FX_POSITION& rNextPosition,
35 void*& rKey, 35 void*& rKey,
36 void*& rValue) const { 36 void*& rValue) const {
37 ASSERT(m_pHashTable); 37 ASSERT(m_pHashTable);
38 CAssoc* pAssocRet = (CAssoc*)rNextPosition; 38 CAssoc* pAssocRet = (CAssoc*)rNextPosition;
39 ASSERT(pAssocRet); 39 ASSERT(pAssocRet);
40 if (pAssocRet == (CAssoc*)-1) { 40 if (pAssocRet == (CAssoc*)-1) {
41 for (FX_DWORD nBucket = 0; nBucket < m_nHashTableSize; nBucket++) { 41 for (uint32_t nBucket = 0; nBucket < m_nHashTableSize; nBucket++) {
42 pAssocRet = m_pHashTable[nBucket]; 42 pAssocRet = m_pHashTable[nBucket];
43 if (pAssocRet) 43 if (pAssocRet)
44 break; 44 break;
45 } 45 }
46 ASSERT(pAssocRet); 46 ASSERT(pAssocRet);
47 } 47 }
48 CAssoc* pAssocNext = pAssocRet->pNext; 48 CAssoc* pAssocNext = pAssocRet->pNext;
49 for (FX_DWORD nBucket = (HashKey(pAssocRet->key) % m_nHashTableSize) + 1; 49 for (uint32_t nBucket = (HashKey(pAssocRet->key) % m_nHashTableSize) + 1;
50 nBucket < m_nHashTableSize && !pAssocNext; nBucket++) { 50 nBucket < m_nHashTableSize && !pAssocNext; nBucket++) {
51 pAssocNext = m_pHashTable[nBucket]; 51 pAssocNext = m_pHashTable[nBucket];
52 } 52 }
53 rNextPosition = (FX_POSITION)pAssocNext; 53 rNextPosition = (FX_POSITION)pAssocNext;
54 rKey = pAssocRet->key; 54 rKey = pAssocRet->key;
55 rValue = pAssocRet->value; 55 rValue = pAssocRet->value;
56 } 56 }
57 FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const { 57 FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const {
58 FX_DWORD nHash; 58 uint32_t nHash;
59 CAssoc* pAssoc = GetAssocAt(key, nHash); 59 CAssoc* pAssoc = GetAssocAt(key, nHash);
60 if (!pAssoc) { 60 if (!pAssoc) {
61 return FALSE; 61 return FALSE;
62 } 62 }
63 rValue = pAssoc->value; 63 rValue = pAssoc->value;
64 return TRUE; 64 return TRUE;
65 } 65 }
66 void* CFX_MapPtrToPtr::GetValueAt(void* key) const { 66 void* CFX_MapPtrToPtr::GetValueAt(void* key) const {
67 FX_DWORD nHash; 67 uint32_t nHash;
68 CAssoc* pAssoc = GetAssocAt(key, nHash); 68 CAssoc* pAssoc = GetAssocAt(key, nHash);
69 if (!pAssoc) { 69 if (!pAssoc) {
70 return NULL; 70 return NULL;
71 } 71 }
72 return pAssoc->value; 72 return pAssoc->value;
73 } 73 }
74 void*& CFX_MapPtrToPtr::operator[](void* key) { 74 void*& CFX_MapPtrToPtr::operator[](void* key) {
75 FX_DWORD nHash; 75 uint32_t nHash;
76 CAssoc* pAssoc; 76 CAssoc* pAssoc;
77 if ((pAssoc = GetAssocAt(key, nHash)) == NULL) { 77 if ((pAssoc = GetAssocAt(key, nHash)) == NULL) {
78 if (!m_pHashTable) { 78 if (!m_pHashTable) {
79 InitHashTable(m_nHashTableSize); 79 InitHashTable(m_nHashTableSize);
80 } 80 }
81 pAssoc = NewAssoc(); 81 pAssoc = NewAssoc();
82 pAssoc->key = key; 82 pAssoc->key = key;
83 pAssoc->pNext = m_pHashTable[nHash]; 83 pAssoc->pNext = m_pHashTable[nHash];
84 m_pHashTable[nHash] = pAssoc; 84 m_pHashTable[nHash] = pAssoc;
85 } 85 }
86 return pAssoc->value; 86 return pAssoc->value;
87 } 87 }
88 CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::GetAssocAt(void* key, 88 CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::GetAssocAt(void* key,
89 FX_DWORD& nHash) const { 89 uint32_t& nHash) const {
90 nHash = HashKey(key) % m_nHashTableSize; 90 nHash = HashKey(key) % m_nHashTableSize;
91 if (!m_pHashTable) { 91 if (!m_pHashTable) {
92 return NULL; 92 return NULL;
93 } 93 }
94 CAssoc* pAssoc; 94 CAssoc* pAssoc;
95 for (pAssoc = m_pHashTable[nHash]; pAssoc; pAssoc = pAssoc->pNext) { 95 for (pAssoc = m_pHashTable[nHash]; pAssoc; pAssoc = pAssoc->pNext) {
96 if (pAssoc->key == key) 96 if (pAssoc->key == key)
97 return pAssoc; 97 return pAssoc;
98 } 98 }
99 return NULL; 99 return NULL;
(...skipping 11 matching lines...) Expand all
111 } 111 }
112 } 112 }
113 CFX_MapPtrToPtr::CAssoc* pAssoc = m_pFreeList; 113 CFX_MapPtrToPtr::CAssoc* pAssoc = m_pFreeList;
114 m_pFreeList = m_pFreeList->pNext; 114 m_pFreeList = m_pFreeList->pNext;
115 m_nCount++; 115 m_nCount++;
116 ASSERT(m_nCount > 0); 116 ASSERT(m_nCount > 0);
117 pAssoc->key = 0; 117 pAssoc->key = 0;
118 pAssoc->value = 0; 118 pAssoc->value = 0;
119 return pAssoc; 119 return pAssoc;
120 } 120 }
121 void CFX_MapPtrToPtr::InitHashTable(FX_DWORD nHashSize, FX_BOOL bAllocNow) { 121 void CFX_MapPtrToPtr::InitHashTable(uint32_t nHashSize, FX_BOOL bAllocNow) {
122 ASSERT(m_nCount == 0); 122 ASSERT(m_nCount == 0);
123 ASSERT(nHashSize > 0); 123 ASSERT(nHashSize > 0);
124 FX_Free(m_pHashTable); 124 FX_Free(m_pHashTable);
125 m_pHashTable = NULL; 125 m_pHashTable = NULL;
126 if (bAllocNow) { 126 if (bAllocNow) {
127 m_pHashTable = FX_Alloc(CAssoc*, nHashSize); 127 m_pHashTable = FX_Alloc(CAssoc*, nHashSize);
128 } 128 }
129 m_nHashTableSize = nHashSize; 129 m_nHashTableSize = nHashSize;
130 } 130 }
131 FX_BOOL CFX_MapPtrToPtr::RemoveKey(void* key) { 131 FX_BOOL CFX_MapPtrToPtr::RemoveKey(void* key) {
(...skipping 15 matching lines...) Expand all
147 } 147 }
148 void CFX_MapPtrToPtr::FreeAssoc(CFX_MapPtrToPtr::CAssoc* pAssoc) { 148 void CFX_MapPtrToPtr::FreeAssoc(CFX_MapPtrToPtr::CAssoc* pAssoc) {
149 pAssoc->pNext = m_pFreeList; 149 pAssoc->pNext = m_pFreeList;
150 m_pFreeList = pAssoc; 150 m_pFreeList = pAssoc;
151 m_nCount--; 151 m_nCount--;
152 ASSERT(m_nCount >= 0); 152 ASSERT(m_nCount >= 0);
153 if (m_nCount == 0) { 153 if (m_nCount == 0) {
154 RemoveAll(); 154 RemoveAll();
155 } 155 }
156 } 156 }
OLDNEW
« no previous file with comments | « core/fxcrt/fx_basic_gcc.cpp ('k') | core/fxcrt/fx_basic_plex.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698