| 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 "../../include/fxcrt/fx_ext.h" | 7 #include "../../include/fxcrt/fx_ext.h" |
| 8 #include "plex.h" | 8 #include "plex.h" |
| 9 static void ConstructElement(CFX_ByteString* pNewData) | 9 static void ConstructElement(CFX_ByteString* pNewData) |
| 10 { | 10 { |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 345 } |
| 346 if (bAllocNow) { | 346 if (bAllocNow) { |
| 347 m_pHashTable = FX_Alloc(CAssoc*, nHashSize); | 347 m_pHashTable = FX_Alloc(CAssoc*, nHashSize); |
| 348 } | 348 } |
| 349 m_nHashTableSize = nHashSize; | 349 m_nHashTableSize = nHashSize; |
| 350 } | 350 } |
| 351 inline FX_DWORD CFX_MapByteStringToPtr::HashKey(FX_BSTR key) const | 351 inline FX_DWORD CFX_MapByteStringToPtr::HashKey(FX_BSTR key) const |
| 352 { | 352 { |
| 353 FX_DWORD nHash = 0; | 353 FX_DWORD nHash = 0; |
| 354 int len = key.GetLength(); | 354 int len = key.GetLength(); |
| 355 FX_LPCBYTE buf = key; | 355 FX_LPCBYTE buf = key.GetPtr(); |
| 356 for (int i = 0; i < len; i ++) { | 356 for (int i = 0; i < len; i ++) { |
| 357 nHash = (nHash << 5) + nHash + buf[i]; | 357 nHash = (nHash << 5) + nHash + buf[i]; |
| 358 } | 358 } |
| 359 return nHash; | 359 return nHash; |
| 360 } | 360 } |
| 361 FX_BOOL CFX_MapByteStringToPtr::RemoveKey(FX_BSTR key) | 361 FX_BOOL CFX_MapByteStringToPtr::RemoveKey(FX_BSTR key) |
| 362 { | 362 { |
| 363 if (m_pHashTable == NULL) { | 363 if (m_pHashTable == NULL) { |
| 364 return FALSE; | 364 return FALSE; |
| 365 } | 365 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 rValue = *(void**)((_CompactString*)p + 1); | 511 rValue = *(void**)((_CompactString*)p + 1); |
| 512 return TRUE; | 512 return TRUE; |
| 513 } | 513 } |
| 514 void CFX_CMapByteStringToPtr::SetAt(FX_BSTR key, void* value) | 514 void CFX_CMapByteStringToPtr::SetAt(FX_BSTR key, void* value) |
| 515 { | 515 { |
| 516 ASSERT(value != NULL); | 516 ASSERT(value != NULL); |
| 517 int index, key_len = key.GetLength(); | 517 int index, key_len = key.GetLength(); |
| 518 int size = m_Buffer.GetSize(); | 518 int size = m_Buffer.GetSize(); |
| 519 for (index = 0; index < size; index ++) { | 519 for (index = 0; index < size; index ++) { |
| 520 _CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index); | 520 _CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index); |
| 521 if (!_CompactStringSame(pKey, (FX_LPCBYTE)key, key_len)) { | 521 if (!_CompactStringSame(pKey, key.GetPtr(), key_len)) { |
| 522 continue; | 522 continue; |
| 523 } | 523 } |
| 524 *(void**)(pKey + 1) = value; | 524 *(void**)(pKey + 1) = value; |
| 525 return; | 525 return; |
| 526 } | 526 } |
| 527 for (index = 0; index < size; index ++) { | 527 for (index = 0; index < size; index ++) { |
| 528 _CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index); | 528 _CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index); |
| 529 if (pKey->m_CompactLen) { | 529 if (pKey->m_CompactLen) { |
| 530 continue; | 530 continue; |
| 531 } | 531 } |
| 532 _CompactStringStore(pKey, (FX_LPCBYTE)key, key_len); | 532 _CompactStringStore(pKey, key.GetPtr(), key_len); |
| 533 *(void**)(pKey + 1) = value; | 533 *(void**)(pKey + 1) = value; |
| 534 return; | 534 return; |
| 535 } | 535 } |
| 536 _CompactString* pKey = (_CompactString*)m_Buffer.Add(); | 536 _CompactString* pKey = (_CompactString*)m_Buffer.Add(); |
| 537 _CompactStringStore(pKey, (FX_LPCBYTE)key, key_len); | 537 _CompactStringStore(pKey, key.GetPtr(), key_len); |
| 538 *(void**)(pKey + 1) = value; | 538 *(void**)(pKey + 1) = value; |
| 539 } | 539 } |
| 540 void CFX_CMapByteStringToPtr::AddValue(FX_BSTR key, void* value) | 540 void CFX_CMapByteStringToPtr::AddValue(FX_BSTR key, void* value) |
| 541 { | 541 { |
| 542 ASSERT(value != NULL); | 542 ASSERT(value != NULL); |
| 543 _CompactString* pKey = (_CompactString*)m_Buffer.Add(); | 543 _CompactString* pKey = (_CompactString*)m_Buffer.Add(); |
| 544 _CompactStringStore(pKey, (FX_LPCBYTE)key, key.GetLength()); | 544 _CompactStringStore(pKey, key.GetPtr(), key.GetLength()); |
| 545 *(void**)(pKey + 1) = value; | 545 *(void**)(pKey + 1) = value; |
| 546 } | 546 } |
| 547 void CFX_CMapByteStringToPtr::RemoveKey(FX_BSTR key) | 547 void CFX_CMapByteStringToPtr::RemoveKey(FX_BSTR key) |
| 548 { | 548 { |
| 549 int key_len = key.GetLength(); | 549 int key_len = key.GetLength(); |
| 550 int size = m_Buffer.GetSize(); | 550 int size = m_Buffer.GetSize(); |
| 551 for (int index = 0; index < size; index++) { | 551 for (int index = 0; index < size; index++) { |
| 552 _CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index); | 552 _CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index); |
| 553 if (!_CompactStringSame(pKey, (FX_LPCBYTE)key, key_len)) { | 553 if (!_CompactStringSame(pKey, key.GetPtr(), key_len)) { |
| 554 continue; | 554 continue; |
| 555 } | 555 } |
| 556 _CompactStringRelease(pKey); | 556 _CompactStringRelease(pKey); |
| 557 pKey->m_CompactLen = 0xfe; | 557 pKey->m_CompactLen = 0xfe; |
| 558 return; | 558 return; |
| 559 } | 559 } |
| 560 } | 560 } |
| 561 int CFX_CMapByteStringToPtr::GetCount() const | 561 int CFX_CMapByteStringToPtr::GetCount() const |
| 562 { | 562 { |
| 563 int count = 0; | 563 int count = 0; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 buf[mid].value = value; | 634 buf[mid].value = value; |
| 635 return; | 635 return; |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 m_Buffer.InsertBlock(low * sizeof(_DWordPair), &pair, sizeof(_DWordPair)); | 638 m_Buffer.InsertBlock(low * sizeof(_DWordPair), &pair, sizeof(_DWordPair)); |
| 639 } | 639 } |
| 640 void CFX_CMapDWordToDWord::EstimateSize(FX_DWORD size, FX_DWORD grow_by) | 640 void CFX_CMapDWordToDWord::EstimateSize(FX_DWORD size, FX_DWORD grow_by) |
| 641 { | 641 { |
| 642 m_Buffer.EstimateSize(size, grow_by); | 642 m_Buffer.EstimateSize(size, grow_by); |
| 643 } | 643 } |
| OLD | NEW |