diff options
Diffstat (limited to 'include/m_string.h')
-rw-r--r-- | include/m_string.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/m_string.h b/include/m_string.h index 188802bc08b..969725e4631 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -231,4 +231,15 @@ static inline void lex_string_set(LEX_STRING *lex_str, const char *c_str) lex_str->length= strlen(c_str); } +#ifdef __cplusplus +static inline char *safe_str(char *str) +{ return str ? str : const_cast<char*>(""); } +#endif + +static inline const char *safe_str(const char *str) +{ return str ? str : ""; } + +static inline size_t safe_strlen(const char *str) +{ return str ? strlen(str) : 0; } + #endif |