From e2ff67371093bbfba98989287b0903a145a67c65 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 26 Aug 2016 02:37:15 +0200 Subject: [PATCH] Add verbosity in debug. --- src/upnp.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/upnp.cpp b/src/upnp.cpp index 435bb14..4e5f103 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -35,6 +35,20 @@ namespace kuu { namespace { + void freeUPNPDevlist (struct UPNPDev* parDele) { +#if defined(KUU_VERBOSE) + std::cout << "Deleting UPNPDev " << parDele << '\n'; +#endif + ::freeUPNPDevlist(parDele); + } + + void FreeUPNPUrls (struct UPNPUrls* parDele) { +#if defined(KUU_VERBOSE) + std::cout << "Deleting UPNPUrls " << parDele << '\n'; +#endif + ::FreeUPNPUrls(parDele); + } + struct UPNPUrlsWithInitFlag { UPNPUrlsWithInitFlag() : initialized(false) {} struct UPNPUrls urls; @@ -50,7 +64,7 @@ namespace kuu { void operator() (UPNPUrlsWithInitFlag& parUrls) { if (parUrls.initialized) { parUrls.initialized = false; - FreeUPNPUrls(&parUrls.urls); + kuu::FreeUPNPUrls(&parUrls.urls); } } }; @@ -112,7 +126,6 @@ namespace kuu { std::cout << "External ip address: " << parExternalAddr << '\n'; } #endif - } //unnamed namespace struct UPNP::LocalData { @@ -121,10 +134,16 @@ namespace kuu { lanaddr(), externaladdr(), igd_reply(IGDNone), - devlist(nullptr, &freeUPNPDevlist) + devlist(nullptr, &kuu::freeUPNPDevlist) { } + ~LocalData() noexcept { +#if defined(KUU_VERBOSE) + std::cout << "Destroying LocalData " << this << '\n'; +#endif + } + std::string lanaddr; std::string externaladdr; struct IGDdatas data; @@ -147,7 +166,7 @@ namespace kuu { 2, //ttl &error ), - &freeUPNPDevlist + &kuu::freeUPNPDevlist ); if (error) throw UPNPException(error, "Error initializing upnpc in upnpDiscover()", nullptr);