| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 // Now round to an 8-byte boundary. We'd expect that this is the minimum | 27 // Now round to an 8-byte boundary. We'd expect that this is the minimum |
| 28 // granularity of any of the underlying allocators, so there may be cases | 28 // granularity of any of the underlying allocators, so there may be cases |
| 29 // where we can save a re-alloc when adding a few characters to a string | 29 // where we can save a re-alloc when adding a few characters to a string |
| 30 // by using this otherwise wasted space. | 30 // by using this otherwise wasted space. |
| 31 iSize += 7; | 31 iSize += 7; |
| 32 int totalSize = iSize.ValueOrDie() & ~7; | 32 int totalSize = iSize.ValueOrDie() & ~7; |
| 33 int usableLen = (totalSize - overhead) / sizeof(FX_WCHAR); | 33 int usableLen = (totalSize - overhead) / sizeof(FX_WCHAR); |
| 34 FXSYS_assert(usableLen >= nLen); | 34 FXSYS_assert(usableLen >= nLen); |
| 35 | 35 |
| 36 void* pData = FX_Alloc(FX_BYTE, iSize.ValueOrDie()); | 36 void* pData = FX_Alloc(uint8_t, iSize.ValueOrDie()); |
| 37 return new (pData) StringData(nLen, usableLen); | 37 return new (pData) StringData(nLen, usableLen); |
| 38 } | 38 } |
| 39 CFX_WideString::~CFX_WideString() | 39 CFX_WideString::~CFX_WideString() |
| 40 { | 40 { |
| 41 if (m_pData) { | 41 if (m_pData) { |
| 42 m_pData->Release(); | 42 m_pData->Release(); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) | 45 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) |
| 46 { | 46 { |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 } | 904 } |
| 905 } else { | 905 } else { |
| 906 switch (*lpsz) { | 906 switch (*lpsz) { |
| 907 case 'd': | 907 case 'd': |
| 908 case 'i': | 908 case 'i': |
| 909 case 'u': | 909 case 'u': |
| 910 case 'x': | 910 case 'x': |
| 911 case 'X': | 911 case 'X': |
| 912 case 'o': | 912 case 'o': |
| 913 if (nModifier & FORCE_INT64) { | 913 if (nModifier & FORCE_INT64) { |
| 914 va_arg(argList, FX_INT64); | 914 va_arg(argList, int64_t); |
| 915 } else { | 915 } else { |
| 916 va_arg(argList, int); | 916 va_arg(argList, int); |
| 917 } | 917 } |
| 918 nItemLen = 32; | 918 nItemLen = 32; |
| 919 if (nItemLen < nWidth + nPrecision) { | 919 if (nItemLen < nWidth + nPrecision) { |
| 920 nItemLen = nWidth + nPrecision; | 920 nItemLen = nWidth + nPrecision; |
| 921 } | 921 } |
| 922 break; | 922 break; |
| 923 case 'a': | 923 case 'a': |
| 924 case 'A': | 924 case 'A': |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 } | 1061 } |
| 1062 static int _DefMap_GetBig5CodePage() | 1062 static int _DefMap_GetBig5CodePage() |
| 1063 { | 1063 { |
| 1064 return 950; | 1064 return 950; |
| 1065 } | 1065 } |
| 1066 static const CFX_CharMap g_DefaultMapper = {&_DefMap_GetWideString, &_DefMap_Get
ByteString, NULL}; | 1066 static const CFX_CharMap g_DefaultMapper = {&_DefMap_GetWideString, &_DefMap_Get
ByteString, NULL}; |
| 1067 static const CFX_CharMap g_DefaultGBKMapper = {&_DefMap_GetWideString, &_DefMap_
GetByteString, &_DefMap_GetGBKCodePage}; | 1067 static const CFX_CharMap g_DefaultGBKMapper = {&_DefMap_GetWideString, &_DefMap_
GetByteString, &_DefMap_GetGBKCodePage}; |
| 1068 static const CFX_CharMap g_DefaultJISMapper = {&_DefMap_GetWideString, &_DefMap_
GetByteString, &_DefMap_GetJISCodePage}; | 1068 static const CFX_CharMap g_DefaultJISMapper = {&_DefMap_GetWideString, &_DefMap_
GetByteString, &_DefMap_GetJISCodePage}; |
| 1069 static const CFX_CharMap g_DefaultUHCMapper = {&_DefMap_GetWideString, &_DefMap_
GetByteString, &_DefMap_GetUHCCodePage}; | 1069 static const CFX_CharMap g_DefaultUHCMapper = {&_DefMap_GetWideString, &_DefMap_
GetByteString, &_DefMap_GetUHCCodePage}; |
| 1070 static const CFX_CharMap g_DefaultBig5Mapper = {&_DefMap_GetWideString, &_DefMap
_GetByteString, &_DefMap_GetBig5CodePage}; | 1070 static const CFX_CharMap g_DefaultBig5Mapper = {&_DefMap_GetWideString, &_DefMap
_GetByteString, &_DefMap_GetBig5CodePage}; |
| 1071 CFX_CharMap* CFX_CharMap::GetDefaultMapper(FX_INT32 codepage) | 1071 CFX_CharMap* CFX_CharMap::GetDefaultMapper(int32_t codepage) |
| 1072 { | 1072 { |
| 1073 switch (codepage) { | 1073 switch (codepage) { |
| 1074 case 0: | 1074 case 0: |
| 1075 return (CFX_CharMap*)&g_DefaultMapper; | 1075 return (CFX_CharMap*)&g_DefaultMapper; |
| 1076 case 932: | 1076 case 932: |
| 1077 return (CFX_CharMap*)&g_DefaultJISMapper; | 1077 return (CFX_CharMap*)&g_DefaultJISMapper; |
| 1078 case 936: | 1078 case 936: |
| 1079 return (CFX_CharMap*)&g_DefaultGBKMapper; | 1079 return (CFX_CharMap*)&g_DefaultGBKMapper; |
| 1080 case 949: | 1080 case 949: |
| 1081 return (CFX_CharMap*)&g_DefaultUHCMapper; | 1081 return (CFX_CharMap*)&g_DefaultUHCMapper; |
| 1082 case 950: | 1082 case 950: |
| 1083 return (CFX_CharMap*)&g_DefaultBig5Mapper; | 1083 return (CFX_CharMap*)&g_DefaultBig5Mapper; |
| 1084 } | 1084 } |
| 1085 return NULL; | 1085 return NULL; |
| 1086 } | 1086 } |
| OLD | NEW |