[Ffmpeg-devel] [PATCH] from DivX, Patch 10: memory leaks
Michael Niedermayer
michaelni
Sat Dec 17 12:57:55 CET 2005
Hi
On Fri, Dec 16, 2005 at 02:42:12PM -1000, Steve Lhomme wrote:
> As the title suggests, a few memory leaks removed.
> Index: ffmpeg.c
> ===================================================================
> RCS file: /cvsroot/ffmpeg/ffmpeg/ffmpeg.c,v
> retrieving revision 1.355
> diff -u -r1.355 ffmpeg.c
> --- ffmpeg.c 12 Dec 2005 01:56:45 -0000 1.355
> +++ ffmpeg.c 17 Dec 2005 00:23:37 -0000
> @@ -441,16 +441,16 @@
>
> #define MAX_AUDIO_PACKET_SIZE (128 * 1024)
>
> +static uint8_t *audio_buf = NULL;
> +static uint8_t *audio_out = NULL;
> +const int audio_out_size= 4*MAX_AUDIO_PACKET_SIZE;
> +
> static void do_audio_out(AVFormatContext *s,
> AVOutputStream *ost,
> AVInputStream *ist,
> unsigned char *buf, int size)
> {
> uint8_t *buftmp;
> - static uint8_t *audio_buf = NULL;
> - static uint8_t *audio_out = NULL;
> - const int audio_out_size= 4*MAX_AUDIO_PACKET_SIZE;
hmm, shouldnt these be freed automatically on exit? ffmpeg.c isnt a lib
[...]
> - int size;
> + size_t size;
this is no memleak fix
[...]
> + if (audio_buf != NULL)
> + av_free(audio_buf);
> + if (audio_out != NULL)
> + av_free(audio_out);
> + if (samples != NULL)
> + av_free(samples);
> +
av_free() checks for NULL already
[...]
> -#include "common.h"
> -#include "bitstream.h"
> #include "avcodec.h"
> #include "dsputil.h"
> +#include "bitstream.h"
neither is this a memleak fix
[...]
> +#if __STDC_VERSION__ >= 199901L
> uint64_t counts[2*size];
> int up[2*size];
> +#else
> + uint64_t *counts=alloca(sizeof(uint64_t)*2*size);
> + int *up=alloca(sizeof(int)*2*size);
> +#endif
or that
[...]
--
Michael
More information about the ffmpeg-devel
mailing list