Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: core/src/fxcrt/fx_basic_wstring.cpp

Issue 1143663008: Merge to XFA: Remove FX_Alloc() null checks now that it can't return NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Rebased. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fx_basic_plex.cpp ('k') | core/src/fxcrt/fx_extension.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_plex.cpp ('k') | core/src/fxcrt/fx_extension.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698