Browse Source

return const char * of passphrase

synchronous
Volker Birk 5 years ago
parent
commit
70d668dec6
  1. 14
      passphrase_cache.cc
  2. 2
      passphrase_cache.hh

14
passphrase_cache.cc

@ -1,17 +1,17 @@
#include "passphrase_cache.hh" #include "passphrase_cache.hh"
namespace pEp { namespace pEp {
void PassphraseCache::add(std::string passphrase) const char *PassphraseCache::add(std::string passphrase)
{ {
std::lock_guard<std::mutex> lock(_mtx); std::lock_guard<std::mutex> lock(_mtx);
if (passphrase == "") if (passphrase != "") {
return; while (_cache.size() >= _max_size)
_cache.pop_front();
while (_cache.size() >= _max_size) _cache.emplace_back(cache_entry(passphrase, clock::now()));
_cache.pop_front(); }
_cache.emplace_back(cache_entry(passphrase, clock::now())); return passphrase.c_str();
} }
bool PassphraseCache::for_each_passphrase(const passphrase_callee& callee) bool PassphraseCache::for_each_passphrase(const passphrase_callee& callee)

2
passphrase_cache.hh

@ -38,7 +38,7 @@ namespace pEp {
// adding a passphrase to the cache, which will timeout // adding a passphrase to the cache, which will timeout
void add(std::string passphrase); const char *add(std::string passphrase);
// for each passphrase call the callee until it returns true for a // for each passphrase call the callee until it returns true for a
// matching passphrase or no passphrases are left // matching passphrase or no passphrases are left

Loading…
Cancel
Save