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

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

Issue 880603004: Merge to XFA: Add namespace and-re-arrange PDFium's local copy of /base. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 10 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_bstring.cpp ('k') | core/src/fxcrt/fx_safe_types.h » ('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 "../../include/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 #include "../../../third_party/numerics/safe_math.h" 8 #include "../../../third_party/base/numerics/safe_math.h"
9 9
10 static CFX_StringDataW* FX_AllocStringW(int nLen) 10 static CFX_StringDataW* FX_AllocStringW(int nLen)
11 { 11 {
12 if (nLen == 0 || nLen < 0) { 12 if (nLen == 0 || nLen < 0) {
13 return NULL; 13 return NULL;
14 } 14 }
15 15
16 base::CheckedNumeric<int> iSize = static_cast<int>(sizeof(FX_WCHAR)); 16 pdfium::base::CheckedNumeric<int> iSize = static_cast<int>(sizeof(FX_WCHAR)) ;
17 iSize *= nLen + 1; 17 iSize *= nLen + 1;
18 iSize += sizeof(long) * 3; 18 iSize += sizeof(long) * 3;
19 CFX_StringDataW* pData = (CFX_StringDataW*)FX_Alloc(FX_BYTE, iSize.ValueOrDi e()); 19 CFX_StringDataW* pData = (CFX_StringDataW*)FX_Alloc(FX_BYTE, iSize.ValueOrDi e());
20 if (!pData) { 20 if (!pData) {
21 return NULL; 21 return NULL;
22 } 22 }
23 23
24 // TODO(palmer): |nLen| should really be declared as |size_t|, but for 24 // TODO(palmer): |nLen| should really be declared as |size_t|, but for
25 // now I just want to fix the overflow without changing any interfaces. 25 // now I just want to fix the overflow without changing any interfaces.
26 // Declaring |nLen| as |size_t| will also simplify the above code 26 // Declaring |nLen| as |size_t| will also simplify the above code
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 428
429 429
430 430
431 void CFX_WideString::AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STR SIZE nCopyIndex) const 431 void CFX_WideString::AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STR SIZE nCopyIndex) const
432 { 432 {
433 // |FX_STRSIZE| is currently typedef'd as in |int|. TODO(palmer): It 433 // |FX_STRSIZE| is currently typedef'd as in |int|. TODO(palmer): It
434 // should be a |size_t|, or at least unsigned. 434 // should be a |size_t|, or at least unsigned.
435 if (nCopyLen == 0 || nCopyLen < 0) { 435 if (nCopyLen == 0 || nCopyLen < 0) {
436 return; 436 return;
437 } 437 }
438 base::CheckedNumeric<FX_STRSIZE> iSize = static_cast<FX_STRSIZE>(sizeof(FX_W CHAR)); 438 pdfium::base::CheckedNumeric<FX_STRSIZE> iSize = static_cast<FX_STRSIZE>(siz eof(FX_WCHAR));
439 iSize *= nCopyLen; 439 iSize *= nCopyLen;
440 ASSERT(dest.m_pData == NULL); 440 ASSERT(dest.m_pData == NULL);
441 dest.m_pData = FX_AllocStringW(nCopyLen); 441 dest.m_pData = FX_AllocStringW(nCopyLen);
442 if (dest.m_pData) { 442 if (dest.m_pData) {
443 FXSYS_memcpy32(dest.m_pData->m_String, m_pData->m_String + nCopyIndex, i Size.ValueOrDie()); 443 FXSYS_memcpy32(dest.m_pData->m_String, m_pData->m_String + nCopyIndex, i Size.ValueOrDie());
444 } 444 }
445 } 445 }
446 CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const 446 CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const
447 { 447 {
448 if (m_pData == NULL) { 448 if (m_pData == NULL) {
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 return (CFX_CharMap*)&g_DefaultJISMapper; 1116 return (CFX_CharMap*)&g_DefaultJISMapper;
1117 case 936: 1117 case 936:
1118 return (CFX_CharMap*)&g_DefaultGBKMapper; 1118 return (CFX_CharMap*)&g_DefaultGBKMapper;
1119 case 949: 1119 case 949:
1120 return (CFX_CharMap*)&g_DefaultUHCMapper; 1120 return (CFX_CharMap*)&g_DefaultUHCMapper;
1121 case 950: 1121 case 950:
1122 return (CFX_CharMap*)&g_DefaultBig5Mapper; 1122 return (CFX_CharMap*)&g_DefaultBig5Mapper;
1123 } 1123 }
1124 return NULL; 1124 return NULL;
1125 } 1125 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_safe_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698