Browse Source

use unique_ptr for ElGamalEncryption

pull/177/head
orignal 10 years ago
parent
commit
3983838694
  1. 11
      Identity.h

11
Identity.h

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include <inttypes.h>
#include <string.h>
#include <string>
#include <memory>
#include "base64.h"
#include "ElGamal.h"
#include "Signature.h"
@ -219,23 +220,23 @@ namespace data @@ -219,23 +220,23 @@ namespace data
{
public:
RoutingDestination (): m_ElGamalEncryption (nullptr) {};
virtual ~RoutingDestination () { delete m_ElGamalEncryption; };
RoutingDestination () {};
virtual ~RoutingDestination () {};
virtual const IdentHash& GetIdentHash () const = 0;
virtual const uint8_t * GetEncryptionPublicKey () const = 0;
virtual bool IsDestination () const = 0; // for garlic
const i2p::crypto::ElGamalEncryption * GetElGamalEncryption () const
std::unique_ptr<const i2p::crypto::ElGamalEncryption>& GetElGamalEncryption () const
{
if (!m_ElGamalEncryption)
m_ElGamalEncryption = new i2p::crypto::ElGamalEncryption (GetEncryptionPublicKey ());
m_ElGamalEncryption.reset (new i2p::crypto::ElGamalEncryption (GetEncryptionPublicKey ()));
return m_ElGamalEncryption;
}
private:
mutable i2p::crypto::ElGamalEncryption * m_ElGamalEncryption; // use lazy initialization
mutable std::unique_ptr<const i2p::crypto::ElGamalEncryption> m_ElGamalEncryption; // use lazy initialization
};
class LocalDestination

Loading…
Cancel
Save