summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-14 17:39:09 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-14 17:39:09 -0700
commit80b103bf53ee1249823e6bb3bed9cb2bc15ca67a (patch)
tree65d7415beb59fa3df75361822cd97f3c90e684df /core/fxcrt
parentc3dfb6bbc8763d972c3115fbf5a08f325f2d8960 (diff)
downloadpdfium-80b103bf53ee1249823e6bb3bed9cb2bc15ca67a.tar.xz
Still more comments about strings
TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1888843004
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/include/fx_string.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index 94df35c8e7..2fabee39cf 100644
--- a/core/fxcrt/include/fx_string.h
+++ b/core/fxcrt/include/fx_string.h
@@ -34,18 +34,19 @@ class CFX_ByteStringC {
m_Length = size;
}
+ // Deliberately implicit to avoid calling on every string literal.
CFX_ByteStringC(const FX_CHAR* ptr) {
m_Ptr = (const uint8_t*)ptr;
m_Length = ptr ? FXSYS_strlen(ptr) : 0;
}
+ // Deliberately implicit to avoid calling on every string literal.
// |ch| must be an lvalue that outlives the the CFX_ByteStringC. However,
// the use of char rvalues are not caught at compile time. They are
// implicitly promoted to CFX_ByteString (see below) and then the
// CFX_ByteStringC is constructed from the CFX_ByteString via the alternate
// constructor below. The CFX_ByteString then typically goes out of scope
// and |m_Ptr| may be left pointing to invalid memory. Beware.
- // TODO(tsepez): Mark single-argument string constructors as explicit.
CFX_ByteStringC(FX_CHAR& ch) {
m_Ptr = (const uint8_t*)&ch;
m_Length = 1;
@@ -357,11 +358,19 @@ class CFX_WideStringC {
m_Length = 0;
}
+ // Deliberately implicit to avoid calling on every string literal.
CFX_WideStringC(const FX_WCHAR* ptr) {
m_Ptr = ptr;
m_Length = ptr ? FXSYS_wcslen(ptr) : 0;
}
+ // Deliberately implicit to avoid calling on every string literal.
+ // |ch| must be an lvalue that outlives the the CFX_WideStringC. However,
+ // the use of char rvalues are not caught at compile time. They are
+ // implicitly promoted to CFX_WideString (see below) and then the
+ // CFX_WideStringC is constructed from the CFX_WideString via the alternate
+ // constructor below. The CFX_WideString then typically goes out of scope
+ // and |m_Ptr| may be left pointing to invalid memory. Beware.
CFX_WideStringC(FX_WCHAR& ch) {
m_Ptr = &ch;
m_Length = 1;