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

Side by Side Diff: core/fxcrt/fx_basic_wstring.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 | « core/fxcrt/fx_basic_bstring.cpp ('k') | no next file » | 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return haystack; 52 return haystack;
53 } 53 }
54 } 54 }
55 haystack++; 55 haystack++;
56 } 56 }
57 return nullptr; 57 return nullptr;
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 static_assert(sizeof(CFX_WideString) <= sizeof(FX_WCHAR*),
63 "Strings must not require more space than pointers");
64
62 CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) { 65 CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) {
63 if (nLen < 0) 66 if (nLen < 0)
64 nLen = pStr ? FXSYS_wcslen(pStr) : 0; 67 nLen = pStr ? FXSYS_wcslen(pStr) : 0;
65 68
66 if (nLen) 69 if (nLen)
67 m_pData.Reset(StringData::Create(pStr, nLen)); 70 m_pData.Reset(StringData::Create(pStr, nLen));
68 } 71 }
69 72
70 CFX_WideString::CFX_WideString(FX_WCHAR ch) { 73 CFX_WideString::CFX_WideString(FX_WCHAR ch) {
71 m_pData.Reset(StringData::Create(1)); 74 m_pData.Reset(StringData::Create(1));
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); 986 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0);
984 CFX_WideString wstr; 987 CFX_WideString wstr;
985 if (dest_len) { 988 if (dest_len) {
986 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); 989 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len);
987 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, 990 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf,
988 dest_len); 991 dest_len);
989 wstr.ReleaseBuffer(dest_len); 992 wstr.ReleaseBuffer(dest_len);
990 } 993 }
991 return wstr; 994 return wstr;
992 } 995 }
OLDNEW
« no previous file with comments | « core/fxcrt/fx_basic_bstring.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698