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

Unified Diff: core/include/fxcrt/fx_string.h

Issue 1802553004: Fix offset outside bounds warning on GCC (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Another typo in comment. Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/include/fxcrt/fx_string.h
diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h
index d68fc2cb365c77413125061ccc04ddf59bf75462..9b623b9e71004f520b54b87ddedb00f5a5bb9cfb 100644
--- a/core/include/fxcrt/fx_string.h
+++ b/core/include/fxcrt/fx_string.h
@@ -169,14 +169,22 @@ class CFX_ByteString {
static CFX_ByteString FromUnicode(const CFX_WideString& str);
- // Explicit conversion to raw string
+ // Explicit conversion to C-style string.
const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; }
- // Implicit conversion to C-style string -- deprecated
+ // Implicit conversion to C-style string -- deprecated.
operator const FX_CHAR*() const { return m_pData ? m_pData->m_String : ""; }
+ // Explicit conversion to uint8_t*.
+ const uint8_t* raw_str() const {
+ return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String)
+ : nullptr;
+ }
+
+ // Implicit conversiont to uint8_t* -- deprecated.
operator const uint8_t*() const {
- return m_pData ? (const uint8_t*)m_pData->m_String : NULL;
+ return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String)
+ : nullptr;
}
FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
@@ -569,10 +577,10 @@ class CFX_WideString {
static FX_STRSIZE WStringLength(const unsigned short* str);
- // Explicit conversion to raw string
+ // Explicit conversion to C-style wide string.
const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; }
- // Implicit conversion to C-style wide string -- deprecated
+ // Implicit conversion to C-style wide string -- deprecated.
operator const FX_WCHAR*() const { return m_pData ? m_pData->m_String : L""; }
void Empty();
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698