| 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 static int _Buffer_itoa(char* buf, int i, FX_DWORD flags) | 10 static int _Buffer_itoa(char* buf, int i, FX_DWORD flags) |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 nNewLength = (FX_STRSIZE)FXSYS_strlen((FX_LPCSTR)m_pData->m_String); | 334 nNewLength = (FX_STRSIZE)FXSYS_strlen((FX_LPCSTR)m_pData->m_String); |
| 335 } | 335 } |
| 336 if (nNewLength == 0) { | 336 if (nNewLength == 0) { |
| 337 Empty(); | 337 Empty(); |
| 338 return; | 338 return; |
| 339 } | 339 } |
| 340 FXSYS_assert(nNewLength <= m_pData->m_nAllocLength); | 340 FXSYS_assert(nNewLength <= m_pData->m_nAllocLength); |
| 341 m_pData->m_nDataLength = nNewLength; | 341 m_pData->m_nDataLength = nNewLength; |
| 342 m_pData->m_String[nNewLength] = 0; | 342 m_pData->m_String[nNewLength] = 0; |
| 343 } | 343 } |
| 344 FX_LPSTR CFX_ByteString::LockBuffer() |
| 345 { |
| 346 if (m_pData == NULL) { |
| 347 return NULL; |
| 348 } |
| 349 FX_LPSTR lpsz = GetBuffer(0); |
| 350 m_pData->m_nRefs = -1; |
| 351 return lpsz; |
| 352 } |
| 344 void CFX_ByteString::Reserve(FX_STRSIZE len) | 353 void CFX_ByteString::Reserve(FX_STRSIZE len) |
| 345 { | 354 { |
| 346 GetBuffer(len); | 355 GetBuffer(len); |
| 347 ReleaseBuffer(GetLength()); | 356 ReleaseBuffer(GetLength()); |
| 348 } | 357 } |
| 349 FX_LPSTR CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) | 358 FX_LPSTR CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) |
| 350 { | 359 { |
| 351 if (m_pData == NULL && nMinBufLength == 0) { | 360 if (m_pData == NULL && nMinBufLength == 0) { |
| 352 return NULL; | 361 return NULL; |
| 353 } | 362 } |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 scale /= 10; | 1130 scale /= 10; |
| 1122 } | 1131 } |
| 1123 return buf_size; | 1132 return buf_size; |
| 1124 } | 1133 } |
| 1125 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) | 1134 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) |
| 1126 { | 1135 { |
| 1127 FX_CHAR buf[32]; | 1136 FX_CHAR buf[32]; |
| 1128 FX_STRSIZE len = FX_ftoa(d, buf); | 1137 FX_STRSIZE len = FX_ftoa(d, buf); |
| 1129 return CFX_ByteString(buf, len); | 1138 return CFX_ByteString(buf, len); |
| 1130 } | 1139 } |
| OLD | NEW |