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

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

Issue 900753002: Add namespace and re-arrange PDFium's local copy of chromium /base. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rename safemath target to pdfium_base 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_array.cpp ('k') | core/src/fxcrt/fx_basic_wstring.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 "../../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 int _Buffer_itoa(char* buf, int i, FX_DWORD flags) 10 static int _Buffer_itoa(char* buf, int i, FX_DWORD flags)
11 { 11 {
12 if (i == 0) { 12 if (i == 0) {
13 buf[0] = '0'; 13 buf[0] = '0';
14 return 1; 14 return 1;
15 } 15 }
16 char buf1[32]; 16 char buf1[32];
17 int buf_pos = 31; 17 int buf_pos = 31;
18 FX_DWORD u = i; 18 FX_DWORD u = i;
(...skipping 26 matching lines...) Expand all
45 char buf[32]; 45 char buf[32];
46 return CFX_ByteStringC(buf, _Buffer_itoa(buf, i, flags)); 46 return CFX_ByteStringC(buf, _Buffer_itoa(buf, i, flags));
47 } 47 }
48 static CFX_StringData* FX_AllocString(int nLen) 48 static CFX_StringData* FX_AllocString(int nLen)
49 { 49 {
50 // |nLen| is currently declared as in |int|. TODO(palmer): It should be 50 // |nLen| is currently declared as in |int|. TODO(palmer): It should be
51 // a |size_t|, or at least unsigned. 51 // a |size_t|, or at least unsigned.
52 if (nLen == 0 || nLen < 0) { 52 if (nLen == 0 || nLen < 0) {
53 return NULL; 53 return NULL;
54 } 54 }
55 base::CheckedNumeric<int> nSize = nLen; 55 pdfium::base::CheckedNumeric<int> nSize = nLen;
56 nSize += sizeof(long) * 3 + 1; 56 nSize += sizeof(long) * 3 + 1;
57 CFX_StringData* pData = (CFX_StringData*)FX_Alloc(FX_BYTE, nSize.ValueOrDie( )); 57 CFX_StringData* pData = (CFX_StringData*)FX_Alloc(FX_BYTE, nSize.ValueOrDie( ));
58 if (!pData) { 58 if (!pData) {
59 return NULL; 59 return NULL;
60 } 60 }
61 pData->m_nAllocLength = nLen; 61 pData->m_nAllocLength = nLen;
62 pData->m_nDataLength = nLen; 62 pData->m_nDataLength = nLen;
63 pData->m_nRefs = 1; 63 pData->m_nRefs = 1;
64 pData->m_String[nLen] = 0; 64 pData->m_String[nLen] = 0;
65 return pData; 65 return pData;
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 FX_CHAR* pBuffer = (FX_CHAR*)(this + 1); 1169 FX_CHAR* pBuffer = (FX_CHAR*)(this + 1);
1170 FXSYS_memcpy32(pBuffer + m_Size, str.GetPtr(), len); 1170 FXSYS_memcpy32(pBuffer + m_Size, str.GetPtr(), len);
1171 m_Size += len; 1171 m_Size += len;
1172 } 1172 }
1173 void CFX_StringBufBase::Append(int i, FX_DWORD flags) 1173 void CFX_StringBufBase::Append(int i, FX_DWORD flags)
1174 { 1174 {
1175 char buf[32]; 1175 char buf[32];
1176 int len = _Buffer_itoa(buf, i, flags); 1176 int len = _Buffer_itoa(buf, i, flags);
1177 Append(CFX_ByteStringC(buf, len)); 1177 Append(CFX_ByteStringC(buf, len));
1178 } 1178 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_array.cpp ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698