Skip to content

Commit 9dcc26c

Browse files
committed
Prepare for Crypto++ 8.2 release
Make ConstBytePtr return non-NULL pointer
1 parent ec1aa88 commit 9dcc26c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

misc.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ inline size_t PtrByteDiff(const PTR pointer1, const PTR pointer2)
390390

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

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

415415
/// \brief Size of a string

0 commit comments

Comments
 (0)