1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 00:02:13 +00:00

memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15614 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
faust3 2005-06-02 16:49:29 +00:00
parent b39fbf374d
commit 72ea928194

View File

@ -67,6 +67,9 @@ typedef struct tagAVS
AVS_Value handler; AVS_Value handler;
AVS_Clip *clip; AVS_Clip *clip;
const AVS_VideoInfo *video_info; const AVS_VideoInfo *video_info;
#ifdef WIN32_LOADER
ldt_fs_t* ldt_fs;
#endif
HMODULE dll; HMODULE dll;
int frameno; int frameno;
int init; int init;
@ -91,14 +94,14 @@ AVS_T *initAVS(const char *filename)
memset(AVS, 0, sizeof(AVS_T)); memset(AVS, 0, sizeof(AVS_T));
#ifdef WIN32_LOADER #ifdef WIN32_LOADER
Setup_LDT_Keeper(); AVS->ldt_fs = Setup_LDT_Keeper();
#endif #endif
AVS->dll = LoadLibraryA("avisynth.dll"); AVS->dll = LoadLibraryA("avisynth.dll");
if(!AVS->dll) if(!AVS->dll)
{ {
mp_msg(MSGT_DEMUX ,MSGL_V, "AVS: failed to load avisynth.dll\n"); mp_msg(MSGT_DEMUX ,MSGL_V, "AVS: failed to load avisynth.dll\n");
return NULL; goto avs_err;
} }
/* Dynamic import of needed stuff from avisynth.dll */ /* Dynamic import of needed stuff from avisynth.dll */
@ -116,7 +119,7 @@ AVS_T *initAVS(const char *filename)
if (!AVS->avs_env) if (!AVS->avs_env)
{ {
mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_create_script_environment failed\n"); mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_create_script_environment failed\n");
return NULL; goto avs_err;
} }
@ -125,16 +128,24 @@ AVS_T *initAVS(const char *filename)
if (avs_is_error(AVS->handler)) if (avs_is_error(AVS->handler))
{ {
mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Avisynth error: %s\n", avs_as_string(AVS->handler)); mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Avisynth error: %s\n", avs_as_string(AVS->handler));
return NULL; goto avs_err;
} }
if (!avs_is_clip(AVS->handler)) if (!avs_is_clip(AVS->handler))
{ {
mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Avisynth doesn't return a clip\n"); mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Avisynth doesn't return a clip\n");
return NULL; goto avs_err;
} }
return AVS; return AVS;
avs_err:
if (AVS->dll) FreeLibrary(AVS->dll);
#ifdef WIN32_LOADER
Restore_LDT_Keeper(AVS->ldt_fs);
#endif
free(AVS);
return NULL;
} }
/* Implement RGB MODES ?? */ /* Implement RGB MODES ?? */
@ -354,6 +365,9 @@ void demux_close_avs(demuxer_t* demuxer)
mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Unloading avisynth.dll\n"); mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Unloading avisynth.dll\n");
FreeLibrary(AVS->dll); FreeLibrary(AVS->dll);
} }
#ifdef WIN32_LOADER
Restore_LDT_Keeper(AVS->ldt_fs);
#endif
free(AVS); free(AVS);
} }
} }