[my-place] VisitDetector memory fix. 94/82994/1
authorMarcin Masternak <m.masternak@samsung.com>
Mon, 8 Aug 2016 12:50:08 +0000 (14:50 +0200)
committerMarcin Masternak <m.masternak@samsung.com>
Mon, 8 Aug 2016 12:53:52 +0000 (14:53 +0200)
Change-Id: I11bc198e8223eda2a91548cba4b98dc78832eda5
Signed-off-by: Marcin Masternak <m.masternak@samsung.com>
src/my-place/visit-detector/VisitDetector.cpp

index a7bae95..cde448e 100644 (file)
@@ -68,8 +68,8 @@ typedef void (*visit_categer_t)(ctx::Visit &visit);
 
 ctx::VisitDetector::VisitDetector(time_t startScan, PlaceRecogMode energyMode, bool testMode) :
        __testMode(testMode),
-       __locationLogger(testMode ? nullptr : new LocationLogger(this)),
-       __wifiLogger(testMode ? nullptr : new WifiLogger(this, energyMode)),
+       __locationLogger(testMode ? nullptr : new(std::nothrow) LocationLogger(this)),
+       __wifiLogger(testMode ? nullptr : new(std::nothrow) WifiLogger(this, energyMode)),
        __currentInterval(startScan, startScan + VISIT_DETECTOR_PERIOD_SECONDS_HIGH_ACCURACY),
        __stableCounter(0),
        __tolerance(VISIT_DETECTOR_TOLERANCE_DEPTH),
@@ -78,6 +78,7 @@ ctx::VisitDetector::VisitDetector(time_t startScan, PlaceRecogMode energyMode, b
        __entranceTime(0),
        __departureTime(0)
 {
+       _D("CONSTRUCTOR");
        __setPeriod(energyMode);
        __currentInterval = Interval(startScan, startScan + __periodSeconds);
        __currentMacEvents = std::make_shared<MacEvents>();
@@ -97,6 +98,11 @@ ctx::VisitDetector::VisitDetector(time_t startScan, PlaceRecogMode energyMode, b
 
 ctx::VisitDetector::~VisitDetector()
 {
+       _D("DESTRUCTOR");
+       if (__locationLogger)
+               delete __locationLogger;
+       if (__wifiLogger)
+               delete __wifiLogger;
 }
 
 bool ctx::VisitDetector::__isValid(const ctx::Mac &mac)