+void eEPGCache::FixOverlapping(std::pair<eventMap,timeMap> &servicemap, time_t TM, int duration, const timeMap::iterator &tm_it, const uniqueEPGKey &service)
+{
+ timeMap::iterator tmp = tm_it;
+ while ((tmp->first+tmp->second->getDuration()-300) > TM)
+ {
+ if(tmp->first != TM && tmp->second->type != PRIVATE)
+ {
+ __u16 event_id = tmp->second->getEventID();
+ servicemap.first.erase(event_id);
+#ifdef EPG_DEBUG
+ Event evt((uint8_t*)tmp->second->get());
+ eServiceEvent event;
+ event.parseFrom(&evt, service.sid<<16|service.onid);
+ eDebug("(1)erase no more used event %04x %d\n%s %s\n%s",
+ service.sid, event_id,
+ event.getBeginTimeString().c_str(),
+ event.getEventName().c_str(),
+ event.getExtendedDescription().c_str());
+#endif
+ delete tmp->second;
+ if (tmp == servicemap.second.begin())
+ {
+ servicemap.second.erase(tmp);
+ break;
+ }
+ else
+ servicemap.second.erase(tmp--);
+ }
+ else
+ {
+ if (tmp == servicemap.second.begin())
+ break;
+ --tmp;
+ }
+ }
+
+ tmp = tm_it;
+ while(tmp->first < (TM+duration-300))
+ {
+ if (tmp->first != TM && tmp->second->type != PRIVATE)
+ {
+ __u16 event_id = tmp->second->getEventID();
+ servicemap.first.erase(event_id);
+#ifdef EPG_DEBUG
+ Event evt((uint8_t*)tmp->second->get());
+ eServiceEvent event;
+ event.parseFrom(&evt, service.sid<<16|service.onid);
+ eDebug("(2)erase no more used event %04x %d\n%s %s\n%s",
+ service.sid, event_id,
+ event.getBeginTimeString().c_str(),
+ event.getEventName().c_str(),
+ event.getExtendedDescription().c_str());
+#endif
+ delete tmp->second;
+ servicemap.second.erase(tmp++);
+ }
+ else
+ ++tmp;
+ if (tmp == servicemap.second.end())
+ break;
+ }
+}
+