From 1015188c4eb44787594f55994f88d2b32d04923e Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 3 Sep 2016 16:54:39 -0400 Subject: [PATCH] use shared pointers --- Datagram.h | 13 ++++--------- HTTPServer.cpp | 6 +++--- I2PTunnel.h | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Datagram.h b/Datagram.h index bc358a41..06b3048e 100644 --- a/Datagram.h +++ b/Datagram.h @@ -48,24 +48,19 @@ namespace datagram uint64_t LastSuccess() const { return m_LastSuccess; } struct Info { - const i2p::data::IdentHash * IBGW; - const i2p::data::IdentHash * OBEP; + std::shared_ptr IBGW; + std::shared_ptr OBEP; const uint64_t activity; const uint64_t success; Info() : IBGW(nullptr), OBEP(nullptr), activity(0), success(0) {} Info(const uint8_t * ibgw, const uint8_t * obep, const uint64_t a, const uint64_t s) : activity(a), success(s) { - if(ibgw) IBGW = new i2p::data::IdentHash(ibgw); + if(ibgw) IBGW = std::make_shared(ibgw); else IBGW = nullptr; - if(obep) OBEP = new i2p::data::IdentHash(obep); + if(obep) OBEP = std::make_shared(obep); else OBEP = nullptr; } - ~Info() - { - if(IBGW) delete IBGW; - if(OBEP) delete OBEP; - } }; Info GetSessionInfo() const; diff --git a/HTTPServer.cpp b/HTTPServer.cpp index f1e1e453..01338ff2 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -346,20 +346,20 @@ namespace http { s << "Idle Time"; s << ""; auto forward = i2p::client::context.GetForwardInfosFor(dest->GetIdentHash()); - for (auto & info : forward) + for (auto info : forward) { s << ""; s << "" << info.RemoteIdent.ToBase32() << ""; s << ""; if(info.CurrentIBGW) - s << info.CurrentIBGW->ToBase64().c_str(); + s << std::string(info.CurrentIBGW->ToBase64()); else s << "(none)"; s << ""; s << ""; if(info.CurrentOBEP) - s << info.CurrentOBEP->ToBase64().c_str(); + s << std::string(info.CurrentOBEP->ToBase64()); else s << "(none)"; s << ""; diff --git a/I2PTunnel.h b/I2PTunnel.h index 7fe58574..0d4d85a1 100644 --- a/I2PTunnel.h +++ b/I2PTunnel.h @@ -148,9 +148,9 @@ namespace client /** ident hash of remote destination */ const i2p::data::IdentHash RemoteIdent; /** ident hash of IBGW in use currently in this session or nullptr if none is set */ - const i2p::data::IdentHash * CurrentIBGW; + std::shared_ptr CurrentIBGW; /** ident hash of OBEP in use for this session or nullptr if none is set */ - const i2p::data::IdentHash * CurrentOBEP; + std::shared_ptr CurrentOBEP; /** i2p router's udp endpoint */ const boost::asio::ip::udp::endpoint LocalEndpoint; /** client's udp endpoint */