Skip to content

Commit

Permalink
Prepare for Crypto++ 8.2 release
Browse files Browse the repository at this point in the history
Make ConstBytePtr return non-NULL pointer
  • Loading branch information
noloader committed Apr 28, 2019
1 parent ec1aa88 commit 9dcc26c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ inline size_t PtrByteDiff(const PTR pointer1, const PTR pointer2)

/// \brief Pointer to the first element of a string
/// \param str std::string
/// \details BytePtr returns NULL pointer for an empty string.
/// \return Pointer to the first element of a string
inline byte* BytePtr(std::string& str)
{
Expand All @@ -401,15 +402,14 @@ inline byte* BytePtr(std::string& str)
return reinterpret_cast<byte*>(&str[0]);
}

/// \brief Pointer to the first element of a string
/// \brief Const pointer to the first element of a string
/// \param str std::string
/// \details Use ConstBytePtr if Microsoft compilers match the wrong function.
/// \details ConstBytePtr returns non-NULL pointer for an empty string.
/// \return Pointer to the first element of a string
inline const byte* ConstBytePtr(const std::string& str)
{
if (str.empty())
return NULLPTR;
return reinterpret_cast<const byte*>(&str[0]);
// Use c_str() so a pointer is always available
return reinterpret_cast<const byte*>(str.c_str());
}

/// \brief Size of a string
Expand Down

0 comments on commit 9dcc26c

Please sign in to comment.