Skip to content

Commit

Permalink
Rework cleanup of ConfigInfo and ConfigFile
Browse files Browse the repository at this point in the history
  • Loading branch information
lifenjoiner committed Aug 27, 2022
1 parent 83a9eab commit 497f9ae
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,16 @@ static int ArgParse(int argc, char *argv_ori[])
return 0;
}

static void CleanupConfig(void)
static void CleanupConfigFile(void)
{
if(ConfigInfo.Options.List == NULL)
return;
ConfigFree(&ConfigInfo);
free(ConfigFile);
}

static void CleanupConfigInfo(void)
{
ConfigFree(&ConfigInfo);
}

#ifdef WIN32
static void CleanupWSA(void)
{
Expand Down Expand Up @@ -464,14 +466,14 @@ int main(int argc, char *argv[])

ArgParse(argc, argv);

atexit(CleanupConfig);
if( ConfigFile == NULL )
{
ConfigFile = malloc(320);
if( ConfigFile == NULL )
{
return -264;
}
atexit(CleanupConfigFile);

GetDefaultConfigureFile(ConfigFile, 320);
}
Expand Down Expand Up @@ -499,6 +501,7 @@ int main(int argc, char *argv[])
}
}

atexit(CleanupConfigInfo);
if( EnvironmentInit() != 0 )
{
return -498;
Expand Down

0 comments on commit 497f9ae

Please sign in to comment.