From: nu774 Date: Thu, 17 Jan 2013 08:11:19 +0000 (+0900) Subject: compat_win32: free argv with atexit() X-Git-Tag: v0.1.2~1 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=bfb6aa3cb82b7e9ab858548cfbdd2c01c6769725;p=fdkaac.git compat_win32: free argv with atexit() --- diff --git a/src/compat_win32.c b/src/compat_win32.c index 25c13f0..d640baf 100644 --- a/src/compat_win32.c +++ b/src/compat_win32.c @@ -75,6 +75,17 @@ FILE *aacenc_fopen(const char *name, const char *mode) return fp; } +static char **__aacenc_argv__; + +static +void aacenc_free_mainargs(void) +{ + char **p = __aacenc_argv__; + for (; *p; ++p) + free(*p); + free(__aacenc_argv__); +} + void aacenc_getmainargs(int *argc, char ***argv) { int i; @@ -86,6 +97,8 @@ void aacenc_getmainargs(int *argc, char ***argv) for (i = 0; i < *argc; ++i) codepage_encode_wchar(CP_UTF8, wargv[i], &(*argv)[i]); (*argv)[*argc] = 0; + __aacenc_argv__ = *argv; + atexit(aacenc_free_mainargs); } char *aacenc_to_utf8(const char *s)