]> iEval git - fdkaac.git/commitdiff
compat_win32: free argv with atexit()
authornu774 <honeycomb77@gmail.com>
Thu, 17 Jan 2013 08:11:19 +0000 (17:11 +0900)
committernu774 <honeycomb77@gmail.com>
Thu, 17 Jan 2013 08:11:19 +0000 (17:11 +0900)
src/compat_win32.c

index 25c13f07f5266b0d59278e4bbd9a2431d4809c8b..d640baf0f3095fd7722d9baf12b29837e665de57 100644 (file)
@@ -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)
This page took 0.026503 seconds and 4 git commands to generate.