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

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

Issue 1145843005: Revert "Remove FX_Alloc() null checks now that it can't return NULL." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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 }
37 return new (pData) StringData(nLen, usableLen); 40 return new (pData) StringData(nLen, usableLen);
38 } 41 }
39 CFX_WideString::~CFX_WideString() 42 CFX_WideString::~CFX_WideString()
40 { 43 {
41 if (m_pData) { 44 if (m_pData) {
42 m_pData->Release(); 45 m_pData->Release();
43 } 46 }
44 } 47 }
45 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) 48 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc)
46 { 49 {
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 return (CFX_CharMap*)&g_DefaultJISMapper; 1080 return (CFX_CharMap*)&g_DefaultJISMapper;
1078 case 936: 1081 case 936:
1079 return (CFX_CharMap*)&g_DefaultGBKMapper; 1082 return (CFX_CharMap*)&g_DefaultGBKMapper;
1080 case 949: 1083 case 949:
1081 return (CFX_CharMap*)&g_DefaultUHCMapper; 1084 return (CFX_CharMap*)&g_DefaultUHCMapper;
1082 case 950: 1085 case 950:
1083 return (CFX_CharMap*)&g_DefaultBig5Mapper; 1086 return (CFX_CharMap*)&g_DefaultBig5Mapper;
1084 } 1087 }
1085 return NULL; 1088 return NULL;
1086 } 1089 }
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