aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/string_tools.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-08-02 11:44:31 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-08-16 11:57:46 +0000
commit70271fa7888f44bb6ec11058853256fc3055037f (patch)
treea85ece632226d073641495533cb1e91d96964920 /contrib/epee/include/string_tools.h
parentstore secret keys encrypted where possible (diff)
downloadmonero-70271fa7888f44bb6ec11058853256fc3055037f.tar.xz
common: add a class to safely wrap mlock/munlock
This class will allow mlocking small objects, of which there may be several per page. It adds refcounting so pages are only munlocked when the last object on that page munlocks.
Diffstat (limited to '')
-rw-r--r--contrib/epee/include/string_tools.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h
index 8d8603076..aba065cc7 100644
--- a/contrib/epee/include/string_tools.h
+++ b/contrib/epee/include/string_tools.h
@@ -46,6 +46,7 @@
#include <boost/algorithm/string/predicate.hpp>
#include "hex.h"
#include "memwipe.h"
+#include "mlocker.h"
#include "span.h"
#include "warnings.h"
@@ -358,6 +359,12 @@ POP_WARNINGS
return hex_to_pod(hex_str, unwrap(s));
}
//----------------------------------------------------------------------------
+ template<class t_pod_type>
+ bool hex_to_pod(const std::string& hex_str, epee::mlocked<t_pod_type>& s)
+ {
+ return hex_to_pod(hex_str, unwrap(s));
+ }
+ //----------------------------------------------------------------------------
bool validate_hex(uint64_t length, const std::string& str);
//----------------------------------------------------------------------------
inline std::string get_extension(const std::string& str)