comparison utils.c @ 1994:8d3540dddd1b libavcodec

cleanup & memleak fix
author michael
date Fri, 30 Apr 2004 17:42:58 +0000
parents bc5039adb9af
children f481d3309ad0
comparison
equal deleted inserted replaced
1993:5086ee0ea559 1994:8d3540dddd1b
26 26
27 #include "avcodec.h" 27 #include "avcodec.h"
28 #include "dsputil.h" 28 #include "dsputil.h"
29 #include "mpegvideo.h" 29 #include "mpegvideo.h"
30 #include <stdarg.h> 30 #include <stdarg.h>
31
32 static void avcodec_default_free_buffers(AVCodecContext *s);
31 33
32 void *av_mallocz(unsigned int size) 34 void *av_mallocz(unsigned int size)
33 { 35 {
34 void *ptr; 36 void *ptr;
35 37
512 514
513 int avcodec_close(AVCodecContext *avctx) 515 int avcodec_close(AVCodecContext *avctx)
514 { 516 {
515 if (avctx->codec->close) 517 if (avctx->codec->close)
516 avctx->codec->close(avctx); 518 avctx->codec->close(avctx);
519 avcodec_default_free_buffers(avctx);
517 av_freep(&avctx->priv_data); 520 av_freep(&avctx->priv_data);
518 avctx->codec = NULL; 521 avctx->codec = NULL;
519 return 0; 522 return 0;
520 } 523 }
521 524
736 { 739 {
737 if(avctx->codec->flush) 740 if(avctx->codec->flush)
738 avctx->codec->flush(avctx); 741 avctx->codec->flush(avctx);
739 } 742 }
740 743
741 void avcodec_default_free_buffers(AVCodecContext *s){ 744 static void avcodec_default_free_buffers(AVCodecContext *s){
742 int i, j; 745 int i, j;
743 746
744 if(s->internal_buffer==NULL) return; 747 if(s->internal_buffer==NULL) return;
745 748
746 for(i=0; i<INTERNAL_BUFFER_SIZE; i++){ 749 for(i=0; i<INTERNAL_BUFFER_SIZE; i++){