aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-08-08 18:01:56 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-09 18:32:40 +0200
commit49e5d477a2b8faf410f871396dba97670aa242d9 (patch)
tree1f0e993b595d280d849e44f9e0e9aba12ed61af2
parenta2da17c8608d25f64239047d0ff497adb015e411 (diff)
downloadlibnitrokey-49e5d477a2b8faf410f871396dba97670aa242d9.tar.gz
libnitrokey-49e5d477a2b8faf410f871396dba97670aa242d9.tar.bz2
Move manager instance to shared_ptr
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--NitrokeyManager.cc6
-rw-r--r--include/NitrokeyManager.h6
2 files changed, 6 insertions, 6 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index c6eb51b..3d90338 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -31,7 +31,7 @@ namespace nitrokey{
A::CommandTransaction::run(*device, auth);
}
- NitrokeyManager * NitrokeyManager::_instance = nullptr;
+ shared_ptr <NitrokeyManager> NitrokeyManager::_instance = nullptr;
NitrokeyManager::NitrokeyManager() {
set_debug(true);
@@ -65,9 +65,9 @@ namespace nitrokey{
return device->connect();
}
- NitrokeyManager *NitrokeyManager::instance() {
+ shared_ptr<NitrokeyManager> NitrokeyManager::instance() {
if (_instance == nullptr){
- _instance = new NitrokeyManager();
+ _instance = shared_ptr<NitrokeyManager>(new NitrokeyManager());
}
return _instance;
}
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index 6fa096a..ca8ce78 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -19,7 +19,7 @@ namespace nitrokey {
class NitrokeyManager {
public:
- static NitrokeyManager *instance();
+ static shared_ptr <NitrokeyManager> instance();
bool first_authenticate(const char *pin, const char *temporary_password);
bool write_HOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint8_t hotp_counter,
@@ -81,11 +81,11 @@ namespace nitrokey {
bool is_AES_supported(const char *user_password);
+ ~NitrokeyManager();
private:
NitrokeyManager();
- ~NitrokeyManager();
- static NitrokeyManager *_instance;
+ static shared_ptr <NitrokeyManager> _instance;
bool connected;
std::shared_ptr<Device> device;