StringSource is using "new" operator. Should be deleting the memory or is it auto destroyed?
Dwight Kulkarni <[email protected]> Thu, 27 Apr 2023 10:30:58 -0700 (PDT)
| Newsgroups | gmane.comp.encryption.cryptopp |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I note an example code sample for b64encode(..). I note that there are
"new" calls inside the constructor(..).
The result is returned in the encoded string.
Do I need to do anything to delete the memory from the new calls ?
What happens to the memory in the variable "encoded", if the variable is
passed up to another function and the StringSink is destroyed.
Should I make a copy of encoded and send it on to be safe ?
std::string b64encode(std::string str)
{
std::string encoded;
CryptoPP::StringSource(str, true,
new CryptoPP::Base64Encoder(
new CryptoPP::StringSink(encoded),
false
)
);
return encoded;
}
--
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/16a82f1c-ee0c-450a-85d0-a81d4f5f2a5bn%40googlegroups.com.