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

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

Issue 1904143002: Assert that CFX_ strings are pointer-size. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | core/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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return haystack; 68 return haystack;
69 } 69 }
70 } 70 }
71 haystack++; 71 haystack++;
72 } 72 }
73 return nullptr; 73 return nullptr;
74 } 74 }
75 75
76 } // namespace 76 } // namespace
77 77
78 static_assert(sizeof(CFX_ByteString) <= sizeof(FX_CHAR*),
79 "Strings must not require more space than pointers");
80
78 CFX_ByteString::CFX_ByteString(const FX_CHAR* pStr, FX_STRSIZE nLen) { 81 CFX_ByteString::CFX_ByteString(const FX_CHAR* pStr, FX_STRSIZE nLen) {
79 if (nLen < 0) 82 if (nLen < 0)
80 nLen = pStr ? FXSYS_strlen(pStr) : 0; 83 nLen = pStr ? FXSYS_strlen(pStr) : 0;
81 84
82 if (nLen) 85 if (nLen)
83 m_pData.Reset(StringData::Create(pStr, nLen)); 86 m_pData.Reset(StringData::Create(pStr, nLen));
84 } 87 }
85 88
86 CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) { 89 CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) {
87 if (nLen > 0) { 90 if (nLen > 0) {
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 fraction %= scale; 990 fraction %= scale;
988 scale /= 10; 991 scale /= 10;
989 } 992 }
990 return buf_size; 993 return buf_size;
991 } 994 }
992 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { 995 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) {
993 FX_CHAR buf[32]; 996 FX_CHAR buf[32];
994 FX_STRSIZE len = FX_ftoa(d, buf); 997 FX_STRSIZE len = FX_ftoa(d, buf);
995 return CFX_ByteString(buf, len); 998 return CFX_ByteString(buf, len);
996 } 999 }
OLDNEW
« no previous file with comments | « no previous file | core/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698