NeutrinoMessages fix memleak , ported from tuxbox cvs

This commit is contained in:
satbaby
2012-10-21 18:45:39 +02:00
parent d285f82dca
commit 2c302dc90d
2 changed files with 16 additions and 16 deletions

View File

@@ -298,8 +298,8 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
tuxtxt_start(current_PIDs.PIDs.vtxtpid); tuxtxt_start(current_PIDs.PIDs.vtxtpid);
} }
#endif #endif
t_channel_id * p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = current_channel_id; memcpy(p, &current_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOTPIDS, (const neutrino_msg_data_t)p, false); g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOTPIDS, (const neutrino_msg_data_t)p, false);
processAPIDnames(); processAPIDnames();
@@ -335,8 +335,8 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
{ {
//printf("new program !\n"); //printf("new program !\n");
t_channel_id * p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = current_channel_id; memcpy(p, &current_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg(NeutrinoMessages::EVT_NEXTPROGRAM, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory g_RCInput->postMsg(NeutrinoMessages::EVT_NEXTPROGRAM, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory
return messages_return::handled; return messages_return::handled;
@@ -382,8 +382,8 @@ void CRemoteControl::getSubChannels()
} }
copySubChannelsToZapit(); copySubChannelsToZapit();
t_channel_id * p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = current_channel_id; memcpy(p, &current_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOT_SUBSERVICES, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOT_SUBSERVICES, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory
} }
} }
@@ -424,8 +424,8 @@ void CRemoteControl::getNVODs()
copySubChannelsToZapit(); copySubChannelsToZapit();
t_channel_id * p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = current_channel_id; memcpy(p, &current_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOT_SUBSERVICES, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOT_SUBSERVICES, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory
if ( selected_subchannel == -1 ) if ( selected_subchannel == -1 )
@@ -570,8 +570,8 @@ void CRemoteControl::processAPIDnames()
setAPID( 0 ); setAPID( 0 );
} }
t_channel_id * p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = current_channel_id; memcpy(p, &current_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOTAPIDS, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOTAPIDS, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory
} }

View File

@@ -1273,16 +1273,16 @@ CSectionsdClient::CurrentNextInfo CInfoViewer::getEPG (const t_channel_id for_ch
/* of there is no EPG, send an event so that parental lock can work */ /* of there is no EPG, send an event so that parental lock can work */
if (info.current_uniqueKey == 0 && info.next_uniqueKey == 0) { if (info.current_uniqueKey == 0 && info.next_uniqueKey == 0) {
oldinfo = info; oldinfo = info;
t_channel_id *p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = for_channel_id; memcpy(p, &for_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg (NeutrinoMessages::EVT_NOEPG_YET, (const neutrino_msg_data_t) p, false); g_RCInput->postMsg (NeutrinoMessages::EVT_NOEPG_YET, (const neutrino_msg_data_t) p, false);
return info; return info;
} }
if (info.current_uniqueKey != oldinfo.current_uniqueKey || info.next_uniqueKey != oldinfo.next_uniqueKey) { if (info.current_uniqueKey != oldinfo.current_uniqueKey || info.next_uniqueKey != oldinfo.next_uniqueKey) {
if (info.flags & (CSectionsdClient::epgflags::has_current | CSectionsdClient::epgflags::has_next)) { if (info.flags & (CSectionsdClient::epgflags::has_current | CSectionsdClient::epgflags::has_next)) {
CSectionsdClient::CurrentNextInfo * _info = new CSectionsdClient::CurrentNextInfo; char *_info = new char[sizeof(CSectionsdClient::CurrentNextInfo)];
*_info = info; memcpy(_info, &info, sizeof(CSectionsdClient::CurrentNextInfo));
neutrino_msg_t msg; neutrino_msg_t msg;
if (info.flags & CSectionsdClient::epgflags::has_current) if (info.flags & CSectionsdClient::epgflags::has_current)
msg = NeutrinoMessages::EVT_CURRENTEPG; msg = NeutrinoMessages::EVT_CURRENTEPG;
@@ -1290,8 +1290,8 @@ CSectionsdClient::CurrentNextInfo CInfoViewer::getEPG (const t_channel_id for_ch
msg = NeutrinoMessages::EVT_NEXTEPG; msg = NeutrinoMessages::EVT_NEXTEPG;
g_RCInput->postMsg(msg, (unsigned) _info, false ); g_RCInput->postMsg(msg, (unsigned) _info, false );
} else { } else {
t_channel_id *p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = for_channel_id; memcpy(p, &for_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg (NeutrinoMessages::EVT_NOEPG_YET, (const neutrino_msg_data_t) p, false); // data is pointer to allocated memory g_RCInput->postMsg (NeutrinoMessages::EVT_NOEPG_YET, (const neutrino_msg_data_t) p, false); // data is pointer to allocated memory
} }
oldinfo = info; oldinfo = info;