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/include/fxcrt/fx_basic.h" | 7 #include "core/include/fxcrt/fx_basic.h" |
8 #include "core/src/fxcrt/plex.h" | 8 #include "core/src/fxcrt/plex.h" |
9 | 9 |
10 CFX_MapPtrToPtr::CFX_MapPtrToPtr(int nBlockSize) | 10 CFX_MapPtrToPtr::CFX_MapPtrToPtr(int nBlockSize) |
(...skipping 21 matching lines...) Expand all Loading... |
32 return ((FX_DWORD)(uintptr_t)key) >> 4; | 32 return ((FX_DWORD)(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 (FX_DWORD nBucket = 0; nBucket < m_nHashTableSize; nBucket++) { |
42 if ((pAssocRet = m_pHashTable[nBucket]) != NULL) | 42 if ((pAssocRet = m_pHashTable[nBucket])) |
43 break; | 43 break; |
44 } | 44 } |
45 ASSERT(pAssocRet); | 45 ASSERT(pAssocRet); |
46 } | 46 } |
47 CAssoc* pAssocNext; | 47 CAssoc* pAssocNext; |
48 if ((pAssocNext = pAssocRet->pNext) == NULL) { | 48 if ((pAssocNext = pAssocRet->pNext) == NULL) { |
49 for (FX_DWORD nBucket = (HashKey(pAssocRet->key) % m_nHashTableSize) + 1; | 49 for (FX_DWORD nBucket = (HashKey(pAssocRet->key) % m_nHashTableSize) + 1; |
50 nBucket < m_nHashTableSize; nBucket++) { | 50 nBucket < m_nHashTableSize; nBucket++) { |
51 if ((pAssocNext = m_pHashTable[nBucket]) != NULL) { | 51 if ((pAssocNext = m_pHashTable[nBucket])) { |
52 break; | 52 break; |
53 } | 53 } |
54 } | 54 } |
55 } | 55 } |
56 rNextPosition = (FX_POSITION)pAssocNext; | 56 rNextPosition = (FX_POSITION)pAssocNext; |
57 rKey = pAssocRet->key; | 57 rKey = pAssocRet->key; |
58 rValue = pAssocRet->value; | 58 rValue = pAssocRet->value; |
59 } | 59 } |
60 FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const { | 60 FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const { |
61 FX_DWORD nHash; | 61 FX_DWORD nHash; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 void CFX_MapPtrToPtr::FreeAssoc(CFX_MapPtrToPtr::CAssoc* pAssoc) { | 151 void CFX_MapPtrToPtr::FreeAssoc(CFX_MapPtrToPtr::CAssoc* pAssoc) { |
152 pAssoc->pNext = m_pFreeList; | 152 pAssoc->pNext = m_pFreeList; |
153 m_pFreeList = pAssoc; | 153 m_pFreeList = pAssoc; |
154 m_nCount--; | 154 m_nCount--; |
155 ASSERT(m_nCount >= 0); | 155 ASSERT(m_nCount >= 0); |
156 if (m_nCount == 0) { | 156 if (m_nCount == 0) { |
157 RemoveAll(); | 157 RemoveAll(); |
158 } | 158 } |
159 } | 159 } |
OLD | NEW |