mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Make sha256's factory method return a ref<> instead of a raw pointer.
This commit is contained in:
parent
8e903f2695
commit
7323c38776
@ -49,6 +49,6 @@ HashLibSHA256::HashLibSHA256() {
|
||||
HashLibSHA256::~HashLibSHA256() {
|
||||
}
|
||||
|
||||
SHA256 *HashLibSHA256::_creation_func() {
|
||||
Ref<SHA256> HashLibSHA256::_creation_func() {
|
||||
return new HashLibSHA256();
|
||||
}
|
@ -23,7 +23,7 @@ public:
|
||||
~HashLibSHA256();
|
||||
|
||||
protected:
|
||||
static SHA256 *_creation_func();
|
||||
static Ref<SHA256> _creation_func();
|
||||
|
||||
_SHA256 hasher;
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ SHA256::~SHA256() {
|
||||
|
||||
}
|
||||
|
||||
SHA256 *SHA256::get() {
|
||||
Ref<SHA256> SHA256::get() {
|
||||
if (_sha_256_creation_func == nullptr) {
|
||||
printf("Error: static SHA256 *get(): creation_func == nullptr\n");
|
||||
return nullptr;
|
||||
@ -17,4 +17,4 @@ SHA256 *SHA256::get() {
|
||||
return _sha_256_creation_func();
|
||||
}
|
||||
|
||||
SHA256 *(*SHA256::_sha_256_creation_func)(void) = nullptr;
|
||||
Ref<SHA256> (*SHA256::_sha_256_creation_func)(void) = nullptr;
|
||||
|
@ -18,13 +18,13 @@ public:
|
||||
|
||||
virtual void reset() = 0;
|
||||
|
||||
static SHA256 *get();
|
||||
static Ref<SHA256> get();
|
||||
|
||||
SHA256();
|
||||
virtual ~SHA256();
|
||||
|
||||
protected:
|
||||
static SHA256 *(*_sha_256_creation_func)(void);
|
||||
static Ref<SHA256> (*_sha_256_creation_func)(void);
|
||||
};
|
||||
|
||||
#endif
|
@ -216,7 +216,7 @@ void SessionManager::clear() {
|
||||
String SessionManager::generate_session_id(const String &base) {
|
||||
// todo make something simpler / better
|
||||
|
||||
SHA256 *h = SHA256::get();
|
||||
Ref<SHA256> h = SHA256::get();
|
||||
String sid = base;
|
||||
|
||||
sid += rand();
|
||||
@ -225,8 +225,6 @@ String SessionManager::generate_session_id(const String &base) {
|
||||
sid = h->get_hash();
|
||||
sid.resize(20);
|
||||
|
||||
delete h;
|
||||
|
||||
return sid;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user