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 16 matching lines...) Expand all Loading... |
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(FX_BYTE, iSize.ValueOrDie()); |
37 if (!pData) { | |
38 return NULL; | |
39 } | |
40 return new (pData) StringData(nLen, usableLen); | 37 return new (pData) StringData(nLen, usableLen); |
41 } | 38 } |
42 CFX_WideString::~CFX_WideString() | 39 CFX_WideString::~CFX_WideString() |
43 { | 40 { |
44 if (m_pData) { | 41 if (m_pData) { |
45 m_pData->Release(); | 42 m_pData->Release(); |
46 } | 43 } |
47 } | 44 } |
48 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) | 45 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) |
49 { | 46 { |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 return (CFX_CharMap*)&g_DefaultJISMapper; | 1077 return (CFX_CharMap*)&g_DefaultJISMapper; |
1081 case 936: | 1078 case 936: |
1082 return (CFX_CharMap*)&g_DefaultGBKMapper; | 1079 return (CFX_CharMap*)&g_DefaultGBKMapper; |
1083 case 949: | 1080 case 949: |
1084 return (CFX_CharMap*)&g_DefaultUHCMapper; | 1081 return (CFX_CharMap*)&g_DefaultUHCMapper; |
1085 case 950: | 1082 case 950: |
1086 return (CFX_CharMap*)&g_DefaultBig5Mapper; | 1083 return (CFX_CharMap*)&g_DefaultBig5Mapper; |
1087 } | 1084 } |
1088 return NULL; | 1085 return NULL; |
1089 } | 1086 } |
OLD | NEW |