From b06a79250e90e91dd45c1ea6cf563a678de3a90f Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 18 Nov 2021 16:03:31 +0000 Subject: [PATCH] Change ChannelList back to std::vector, use custom deleter in shared_ptr --- vdr.cc | 5 +++-- vdr.h | 15 ++------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/vdr.cc b/vdr.cc index 6d8a953..9705686 100644 --- a/vdr.cc +++ b/vdr.cc @@ -861,8 +861,9 @@ std::shared_ptr VDR::getChannelsList(ULONG type) VDR_ResponsePacket* vresp = RequestResponse(&vrp); if (vresp->noResponse()) { delete vresp; return NULL; } - //ChannelList* chanList = new ChannelList(); - std::shared_ptr chanList = std::make_shared(); + // shared_ptr for a ChannelList (std::vector) with custom deleter to delete all the Channel* objects + std::shared_ptr chanList(new ChannelList(), + [] (ChannelList* cl) { for (Channel* p : *cl) delete p; }); bool h264support=Video::getInstance()->supportsh264(); bool mpeg2support=Video::getInstance()->supportsmpeg2(); diff --git a/vdr.h b/vdr.h index 8f705c0..adb6178 100644 --- a/vdr.h +++ b/vdr.h @@ -44,11 +44,10 @@ #include "i18n.h" #include "control.h" #include "tcp.h" -#include "channel.h" class RecInfo; class Event; -//class Channel; +class Channel; class VDR_RequestPacket; class VDR_ResponsePacket; #ifdef VOMP_MEDIAPLAYER @@ -59,19 +58,9 @@ class SeriesInfo; class TVMediaInfo; typedef std::vector EventList; -//typedef std::vector ChannelList; +typedef std::vector ChannelList; typedef std::vector RecTimerList; -// Subclass vector to add custom delete behaviour for the contents -class ChannelList : public std::vector -{ - public: - ~ChannelList() - { - for (Channel* p : *this) delete p; - } -}; - struct RecTimerSorter // : public binary_function { bool operator() (const RecTimer* a, const RecTimer* b) -- 2.39.5