| 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 <stddef.h> // For offsetof(). | 7 #include <stddef.h> // For offsetof(). |
| 8 | 8 |
| 9 #include "../../include/fxcrt/fx_basic.h" | 9 #include "../../include/fxcrt/fx_basic.h" |
| 10 #include "../../../third_party/base/numerics/safe_math.h" | 10 #include "../../../third_party/base/numerics/safe_math.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // Now round to an 8-byte boundary. We'd expect that this is the minimum | 26 // Now round to an 8-byte boundary. We'd expect that this is the minimum |
| 27 // granularity of any of the underlying allocators, so there may be cases | 27 // granularity of any of the underlying allocators, so there may be cases |
| 28 // where we can save a re-alloc when adding a few characters to a string | 28 // where we can save a re-alloc when adding a few characters to a string |
| 29 // by using this otherwise wasted space. | 29 // by using this otherwise wasted space. |
| 30 iSize += 7; | 30 iSize += 7; |
| 31 int totalSize = iSize.ValueOrDie() & ~7; | 31 int totalSize = iSize.ValueOrDie() & ~7; |
| 32 int usableLen = (totalSize - overhead) / sizeof(FX_WCHAR); | 32 int usableLen = (totalSize - overhead) / sizeof(FX_WCHAR); |
| 33 FXSYS_assert(usableLen >= nLen); | 33 FXSYS_assert(usableLen >= nLen); |
| 34 | 34 |
| 35 void* pData = FX_Alloc(uint8_t, iSize.ValueOrDie()); | 35 void* pData = FX_Alloc(uint8_t, totalSize); |
| 36 return new (pData) StringData(nLen, usableLen); | 36 return new (pData) StringData(nLen, usableLen); |
| 37 } | 37 } |
| 38 CFX_WideString::~CFX_WideString() { | 38 CFX_WideString::~CFX_WideString() { |
| 39 if (m_pData) { | 39 if (m_pData) { |
| 40 m_pData->Release(); | 40 m_pData->Release(); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) { | 43 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) { |
| 44 if (stringSrc.m_pData == NULL) { | 44 if (stringSrc.m_pData == NULL) { |
| 45 m_pData = NULL; | 45 m_pData = NULL; |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 return (CFX_CharMap*)&g_DefaultJISMapper; | 1057 return (CFX_CharMap*)&g_DefaultJISMapper; |
| 1058 case 936: | 1058 case 936: |
| 1059 return (CFX_CharMap*)&g_DefaultGBKMapper; | 1059 return (CFX_CharMap*)&g_DefaultGBKMapper; |
| 1060 case 949: | 1060 case 949: |
| 1061 return (CFX_CharMap*)&g_DefaultUHCMapper; | 1061 return (CFX_CharMap*)&g_DefaultUHCMapper; |
| 1062 case 950: | 1062 case 950: |
| 1063 return (CFX_CharMap*)&g_DefaultBig5Mapper; | 1063 return (CFX_CharMap*)&g_DefaultBig5Mapper; |
| 1064 } | 1064 } |
| 1065 return NULL; | 1065 return NULL; |
| 1066 } | 1066 } |
| OLD | NEW |