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_basic.h" | 7 #include "../../include/fxcrt/fx_basic.h" |
8 #include "../../../third_party/base/numerics/safe_math.h" | 8 #include "../../../third_party/base/numerics/safe_math.h" |
9 | 9 |
10 CFX_BasicArray::CFX_BasicArray(int unit_size) | 10 CFX_BasicArray::CFX_BasicArray(int unit_size) |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 pSpot[seg_index % m_IndexSize] = pSegment; | 237 pSpot[seg_index % m_IndexSize] = pSegment; |
238 m_DataSize ++; | 238 m_DataSize ++; |
239 return pSegment; | 239 return pSegment; |
240 } | 240 } |
241 void** CFX_BaseSegmentedArray::GetIndex(int seg_index) const | 241 void** CFX_BaseSegmentedArray::GetIndex(int seg_index) const |
242 { | 242 { |
243 ASSERT(m_IndexDepth != 0); | 243 ASSERT(m_IndexDepth != 0); |
244 if (m_IndexDepth == 1) { | 244 if (m_IndexDepth == 1) { |
245 return (void**)m_pIndex; | 245 return (void**)m_pIndex; |
246 } else if (m_IndexDepth == 2) { | 246 } |
| 247 if (m_IndexDepth == 2) { |
247 return (void**)((void**)m_pIndex)[seg_index / m_IndexSize]; | 248 return (void**)((void**)m_pIndex)[seg_index / m_IndexSize]; |
248 } | 249 } |
249 int tree_size = 1; | 250 int tree_size = 1; |
250 int i; | 251 int i; |
251 for (i = 1; i < m_IndexDepth; i ++) { | 252 for (i = 1; i < m_IndexDepth; i ++) { |
252 tree_size *= m_IndexSize; | 253 tree_size *= m_IndexSize; |
253 } | 254 } |
254 void** pSpot = (void**)m_pIndex; | 255 void** pSpot = (void**)m_pIndex; |
255 for (i = 1; i < m_IndexDepth; i ++) { | 256 for (i = 1; i < m_IndexDepth; i ++) { |
256 pSpot = (void**)pSpot[seg_index / tree_size]; | 257 pSpot = (void**)pSpot[seg_index / tree_size]; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 FX_Free(pIndex[i % m_IndexSize]); | 331 FX_Free(pIndex[i % m_IndexSize]); |
331 pIndex[i % m_IndexSize] = NULL; | 332 pIndex[i % m_IndexSize] = NULL; |
332 } | 333 } |
333 } else { | 334 } else { |
334 FX_Free(m_pIndex); | 335 FX_Free(m_pIndex); |
335 m_pIndex = NULL; | 336 m_pIndex = NULL; |
336 } | 337 } |
337 } | 338 } |
338 m_DataSize -= count; | 339 m_DataSize -= count; |
339 } | 340 } |
OLD | NEW |