From 855ea723b0ea450137e54674179751c14e8fc6b5 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 3 Dec 2002 19:40:35 +0000 Subject: [PATCH] * two functions to handle allocation of static data more simple av_mallocz_static - called for every static data table av_free_static - called when ffmpeg is no longer needed and should free all static resources * simple usage shown in mpegaudiodec.c Originally committed as revision 1301 to svn://svn.ffmpeg.org/ffmpeg/trunk --- ffmpeg.c | 1 + libavcodec/avcodec.h | 5 +++++ libavcodec/mpegaudiodec.c | 16 ++++++---------- libavcodec/utils.c | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 9defc3c..2e76f38 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2667,5 +2667,6 @@ int main(int argc, char **argv) for(i=0;i last_static) + array_static = realloc(array_static, l); + array_static[last_static++] = (char**) location; + *location = ptr; + } + return ptr; +} +/* free all static arrays and reset pointers to 0 */ +void av_free_static() +{ + if (array_static) + { + unsigned i; + for (i = 0; i < last_static; i++) + { + free(*array_static[i]); + *array_static[i] = NULL; + } + free(array_static); + array_static = 0; + } + last_static = 0; +} + /* cannot call it directly because of 'void **' casting is not automatic */ void __av_freep(void **ptr) { -- 2.7.4