From 023255ca5d864b6439c404bde173bca95674d48e Mon Sep 17 00:00:00 2001 From: Ewald Snel Date: Tue, 23 Apr 2002 13:52:22 +0000 Subject: Fix memory leaks by disposing unused plugins CVS patchset: 1764 CVS date: 2002/04/23 13:52:22 --- src/xine-engine/load_plugins.c | 62 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 763bd5cfd..47d3b63b3 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: load_plugins.c,v 1.73 2002/04/16 22:22:48 f1rmb Exp $ + * $Id: load_plugins.c,v 1.74 2002/04/23 13:52:22 esnel Exp $ * * * Load input/demux/audio_out/video_out/codec plugins @@ -452,6 +452,8 @@ void load_decoder_plugins (xine_t *this, int i; int spu_prio[DECODER_PLUGIN_MAX], video_prio[DECODER_PLUGIN_MAX], audio_prio[DECODER_PLUGIN_MAX]; + int *spu_used[DECODER_PLUGIN_MAX], *video_used[DECODER_PLUGIN_MAX], + *audio_used[DECODER_PLUGIN_MAX]; if(this == NULL || config == NULL) { @@ -467,18 +469,21 @@ void load_decoder_plugins (xine_t *this, for (i=0; ispu_decoder_plugins[i] = NULL; spu_prio[i] = 0; + spu_used[i] = NULL; } this->cur_video_decoder_plugin = NULL; for (i=0; ivideo_decoder_plugins[i] = NULL; video_prio[i] = 0; + video_used[i] = NULL; } this->cur_audio_decoder_plugin = NULL; for (i=0; iaudio_decoder_plugins[i] = NULL; audio_prio[i] = 0; + audio_used[i] = NULL; } /* @@ -536,18 +541,33 @@ void load_decoder_plugins (xine_t *this, sdp = (spu_decoder_t *) initplug(5, this); if (sdp) { + int *used = (int *)xine_xmalloc (sizeof (int)); + sdp->metronom = this->metronom; for (streamtype = 0; streamtypespu_decoder_plugins[streamtype]->dispose (this->spu_decoder_plugins[streamtype]); + free (spu_used[streamtype]); + } + this->spu_decoder_plugins[streamtype] = sdp; spu_prio[streamtype] = plugin_prio; + spu_used[streamtype] = used; + (*used)++; } xine_log (this, XINE_LOG_PLUGIN, _("spu decoder plugin found : %s\n"), sdp->get_identifier()); + + if (*used == 0) { + sdp->dispose (sdp); + free (used); + } } } } @@ -565,18 +585,33 @@ void load_decoder_plugins (xine_t *this, vdp = (video_decoder_t *) initplug(iface_version, this); if (vdp) { + int *used = (int *)xine_xmalloc (sizeof (int)); + vdp->metronom = this->metronom; for (streamtype = 0; streamtypevideo_decoder_plugins[streamtype]->dispose (this->video_decoder_plugins[streamtype]); + free (video_used[streamtype]); + } + this->video_decoder_plugins[streamtype] = vdp; video_prio[streamtype] = plugin_prio; + video_used[streamtype] = used; + (*used)++; } xine_log (this, XINE_LOG_PLUGIN, _("video decoder plugin found : %s\n"), vdp->get_identifier()); + + if (*used == 0) { + vdp->dispose (vdp); + free (used); + } } } @@ -591,17 +626,31 @@ void load_decoder_plugins (xine_t *this, adp = (audio_decoder_t *) initplug(iface_version, this); if (adp) { + int *used = (int *)xine_xmalloc (sizeof (int)); for (streamtype = 0; streamtypeaudio_decoder_plugins[streamtype]->dispose (this->audio_decoder_plugins[streamtype]); + free (audio_used[streamtype]); + } + this->audio_decoder_plugins[streamtype] = adp; audio_prio[streamtype] = plugin_prio; + audio_used[streamtype] = used; + (*used)++; } xine_log (this, XINE_LOG_PLUGIN, _("audio decoder plugin found : %s\n"), adp->get_identifier()); + + if (*used == 0) { + adp->dispose (adp); + free (used); + } } } @@ -613,6 +662,17 @@ void load_decoder_plugins (xine_t *this, } remove_segv_handler(); + for (i=0; icur_spu_decoder_plugin = NULL; this->cur_video_decoder_plugin = NULL; this->cur_audio_decoder_plugin = NULL; -- cgit v1.2.3