summaryrefslogtreecommitdiff
path: root/core/src/fxcrt
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-08-19 09:55:12 -0700
committerTom Sepez <tsepez@chromium.org>2015-08-19 09:55:12 -0700
commit90b5442f15cecbcf11ac5f6cea3ce612ad863363 (patch)
tree51b6240a8401866380df855818e955348be0bd0f /core/src/fxcrt
parent09d33bcd82a82cb55039d41651df13e17d6c3e59 (diff)
downloadpdfium-90b5442f15cecbcf11ac5f6cea3ce612ad863363.tar.xz
Merge to XFA: FX_CMapDwordToDword considered harmful.
(cherry picked from commit 85d5c4af4a9546970b34dd413c473d10fef8534b) Original Review URL: https://codereview.chromium.org/1289703003 . TBR=thestig@chromium.org Conflicts: core/include/fxcrt/fx_basic.h BUG= Review URL: https://codereview.chromium.org/1302783003 .
Diffstat (limited to 'core/src/fxcrt')
-rw-r--r--core/src/fxcrt/fx_basic_maps.cpp68
1 files changed, 0 insertions, 68 deletions
diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp
index 6bcb91546a..380beb6f89 100644
--- a/core/src/fxcrt/fx_basic_maps.cpp
+++ b/core/src/fxcrt/fx_basic_maps.cpp
@@ -348,71 +348,3 @@ int CFX_CMapByteStringToPtr::GetCount() const {
}
return count;
}
-extern "C" {
-static int _CompareDWord(const void* p1, const void* p2) {
- return (*(FX_DWORD*)p1) - (*(FX_DWORD*)p2);
-}
-};
-struct _DWordPair {
- FX_DWORD key;
- FX_DWORD value;
-};
-FX_BOOL CFX_CMapDWordToDWord::Lookup(FX_DWORD key, FX_DWORD& value) const {
- void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(),
- m_Buffer.GetSize() / sizeof(_DWordPair),
- sizeof(_DWordPair), _CompareDWord);
- if (pResult == NULL) {
- return FALSE;
- }
- value = ((FX_DWORD*)pResult)[1];
- return TRUE;
-}
-FX_POSITION CFX_CMapDWordToDWord::GetStartPosition() const {
- FX_DWORD count = m_Buffer.GetSize() / sizeof(_DWordPair);
- if (count == 0) {
- return NULL;
- }
- return (FX_POSITION)1;
-}
-void CFX_CMapDWordToDWord::GetNextAssoc(FX_POSITION& pos,
- FX_DWORD& key,
- FX_DWORD& value) const {
- if (pos == 0) {
- return;
- }
- FX_DWORD index = ((FX_DWORD)(uintptr_t)pos) - 1;
- FX_DWORD count = m_Buffer.GetSize() / sizeof(_DWordPair);
- _DWordPair* buf = (_DWordPair*)m_Buffer.GetBuffer();
- key = buf[index].key;
- value = buf[index].value;
- if (index == count - 1) {
- pos = 0;
- } else {
- pos = (FX_POSITION)((uintptr_t)pos + 1);
- }
-}
-void CFX_CMapDWordToDWord::SetAt(FX_DWORD key, FX_DWORD value) {
- FX_DWORD count = m_Buffer.GetSize() / sizeof(_DWordPair);
- _DWordPair* buf = (_DWordPair*)m_Buffer.GetBuffer();
- _DWordPair pair = {key, value};
- if (count == 0 || key > buf[count - 1].key) {
- m_Buffer.AppendBlock(&pair, sizeof(_DWordPair));
- return;
- }
- int low = 0, high = count - 1;
- while (low <= high) {
- int mid = (low + high) / 2;
- if (buf[mid].key < key) {
- low = mid + 1;
- } else if (buf[mid].key > key) {
- high = mid - 1;
- } else {
- buf[mid].value = value;
- return;
- }
- }
- m_Buffer.InsertBlock(low * sizeof(_DWordPair), &pair, sizeof(_DWordPair));
-}
-void CFX_CMapDWordToDWord::EstimateSize(FX_DWORD size, FX_DWORD grow_by) {
- m_Buffer.EstimateSize(size, grow_by);
-}