From 70d668dec66de3653eb4780d6c9d4a2a351624a1 Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Sat, 27 Jun 2020 15:46:39 +0200 Subject: [PATCH] return const char * of passphrase --- passphrase_cache.cc | 14 +++++++------- passphrase_cache.hh | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/passphrase_cache.cc b/passphrase_cache.cc index 9f6d37f..4c5d7cc 100644 --- a/passphrase_cache.cc +++ b/passphrase_cache.cc @@ -1,17 +1,17 @@ #include "passphrase_cache.hh" namespace pEp { - void PassphraseCache::add(std::string passphrase) + const char *PassphraseCache::add(std::string passphrase) { std::lock_guard lock(_mtx); - if (passphrase == "") - return; - - while (_cache.size() >= _max_size) - _cache.pop_front(); + if (passphrase != "") { + while (_cache.size() >= _max_size) + _cache.pop_front(); + _cache.emplace_back(cache_entry(passphrase, clock::now())); + } - _cache.emplace_back(cache_entry(passphrase, clock::now())); + return passphrase.c_str(); } bool PassphraseCache::for_each_passphrase(const passphrase_callee& callee) diff --git a/passphrase_cache.hh b/passphrase_cache.hh index b534109..f47490e 100644 --- a/passphrase_cache.hh +++ b/passphrase_cache.hh @@ -38,7 +38,7 @@ namespace pEp { // 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 // matching passphrase or no passphrases are left