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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "core/fxcrt/fx_basic.h" | 10 #include "core/fxcrt/fx_basic.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 void CFX_BinaryBuf::Clear() { | 35 void CFX_BinaryBuf::Clear() { |
36 m_DataSize = 0; | 36 m_DataSize = 0; |
37 } | 37 } |
38 | 38 |
39 uint8_t* CFX_BinaryBuf::DetachBuffer() { | 39 uint8_t* CFX_BinaryBuf::DetachBuffer() { |
40 m_DataSize = 0; | 40 m_DataSize = 0; |
41 m_AllocSize = 0; | 41 m_AllocSize = 0; |
42 return m_pBuffer.release(); | 42 return m_pBuffer.release(); |
43 } | 43 } |
44 | 44 |
45 void CFX_BinaryBuf::AttachData(uint8_t* buffer, FX_STRSIZE size) { | |
46 m_pBuffer.reset(buffer); | |
47 m_DataSize = size; | |
48 m_AllocSize = size; | |
49 } | |
50 | |
51 void CFX_BinaryBuf::EstimateSize(FX_STRSIZE size, FX_STRSIZE step) { | 45 void CFX_BinaryBuf::EstimateSize(FX_STRSIZE size, FX_STRSIZE step) { |
52 m_AllocStep = step; | 46 m_AllocStep = step; |
53 if (m_AllocSize < size) | 47 if (m_AllocSize < size) |
54 ExpandBuf(size - m_DataSize); | 48 ExpandBuf(size - m_DataSize); |
55 } | 49 } |
56 | 50 |
57 void CFX_BinaryBuf::ExpandBuf(FX_STRSIZE add_size) { | 51 void CFX_BinaryBuf::ExpandBuf(FX_STRSIZE add_size) { |
58 FX_SAFE_STRSIZE new_size = m_DataSize; | 52 FX_SAFE_STRSIZE new_size = m_DataSize; |
59 new_size += add_size; | 53 new_size += add_size; |
60 if (m_AllocSize >= new_size.ValueOrDie()) | 54 if (m_AllocSize >= new_size.ValueOrDie()) |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 277 |
284 int32_t CFX_FileBufferArchive::AppendString(const CFX_ByteStringC& lpsz) { | 278 int32_t CFX_FileBufferArchive::AppendString(const CFX_ByteStringC& lpsz) { |
285 return AppendBlock(lpsz.raw_str(), lpsz.GetLength()); | 279 return AppendBlock(lpsz.raw_str(), lpsz.GetLength()); |
286 } | 280 } |
287 | 281 |
288 void CFX_FileBufferArchive::AttachFile( | 282 void CFX_FileBufferArchive::AttachFile( |
289 const CFX_RetainPtr<IFX_WriteStream>& pFile) { | 283 const CFX_RetainPtr<IFX_WriteStream>& pFile) { |
290 ASSERT(pFile); | 284 ASSERT(pFile); |
291 m_pFile = pFile; | 285 m_pFile = pFile; |
292 } | 286 } |
OLD | NEW |