Improving loop management to prevent double freeing. Fixing other memory issues
This commit is contained in:
parent
07d797f24c
commit
df0ad1f5c9
|
|
@ -268,8 +268,15 @@ void shmdatamapcallback(uv_timer_t* handle)
|
|||
//stopui(ms->ui_type, f);
|
||||
// free loop data
|
||||
|
||||
uv_timer_start(&datachecktimer, datacheckcallback, 1000, 1000);
|
||||
if(appstate > 0)
|
||||
{
|
||||
uv_timer_start(&datachecktimer, datacheckcallback, 3000, 1000);
|
||||
}
|
||||
f->releasing = false;
|
||||
if(appstate > 1)
|
||||
{
|
||||
appstate = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -285,7 +292,7 @@ void datacheckcallback(uv_timer_t* handle)
|
|||
{
|
||||
getSim(simdata, simmap, &f->simstate, &f->sim);
|
||||
}
|
||||
if (f->simstate == true)
|
||||
if (f->simstate == true && simdata->simstatus >= 2)
|
||||
{
|
||||
if ( appstate == 1 )
|
||||
{
|
||||
|
|
@ -311,7 +318,7 @@ void cb(uv_poll_t* handle, int status, int events)
|
|||
scanf("%c", &ch);
|
||||
if (ch == 'q')
|
||||
{
|
||||
if(f->releasing == false)
|
||||
if(f->releasing == false && doui == false)
|
||||
{
|
||||
appstate--;
|
||||
slogi("User requested stop appstate is now %i", appstate);
|
||||
|
|
@ -384,6 +391,7 @@ int monocoque_mainloop(MonocoqueSettings* ms)
|
|||
fflush(stdout);
|
||||
tcsetattr(0, TCSANOW, &canonicalmode);
|
||||
|
||||
free(baton);
|
||||
free(simdata);
|
||||
free(simmap);
|
||||
|
||||
|
|
|
|||
|
|
@ -597,3 +597,23 @@ int settingsfree(DeviceSettings ds)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int monocoquesettingsfree(MonocoqueSettings* ms)
|
||||
{
|
||||
if(ms->tyre_diameter_config != NULL)
|
||||
{
|
||||
free(ms->tyre_diameter_config);
|
||||
}
|
||||
if(ms->config_str != NULL)
|
||||
{
|
||||
free(ms->config_str);
|
||||
}
|
||||
if(ms->log_filename_str != NULL)
|
||||
{
|
||||
free(ms->log_filename_str);
|
||||
}
|
||||
if(ms->log_dirname_str != NULL)
|
||||
{
|
||||
free(ms->log_dirname_str);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ typedef struct
|
|||
Simulator sim_name;
|
||||
int configcheck;
|
||||
int useconfig;
|
||||
int verbosity_count;
|
||||
char* tyre_diameter_config;
|
||||
char* config_str;
|
||||
char* log_filename_str;
|
||||
|
|
@ -187,6 +188,8 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
|
|||
|
||||
int settingsfree(DeviceSettings ds);
|
||||
|
||||
int monocoquesettingsfree(MonocoqueSettings* ms);
|
||||
|
||||
int strcicmp(char const *a, char const *b);
|
||||
|
||||
int getconfigtouse(const char* config_file_str, char* car, int sim);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ void SetSettingsFromParameters(Parameters* p, MonocoqueSettings* ms, char* confi
|
|||
ms->log_filename_str = strdup("monocoque.log");
|
||||
}
|
||||
|
||||
ms->verbosity_count = p->verbosity_count;
|
||||
ms->program_action = A_TEST;
|
||||
if (p->program_action == A_PLAY)
|
||||
{
|
||||
|
|
@ -133,11 +134,11 @@ int main(int argc, char** argv)
|
|||
slgCfg.nFlush = 0;
|
||||
slgCfg.nFlags = SLOG_FLAGS_ALL;
|
||||
slog_config_set(&slgCfg);
|
||||
if (p->verbosity_count < 2)
|
||||
if (ms->verbosity_count < 2)
|
||||
{
|
||||
slog_disable(SLOG_TRACE);
|
||||
}
|
||||
if (p->verbosity_count < 1)
|
||||
if (ms->verbosity_count < 1)
|
||||
{
|
||||
slog_disable(SLOG_DEBUG);
|
||||
}
|
||||
|
|
@ -290,10 +291,7 @@ int main(int argc, char** argv)
|
|||
|
||||
cleanup_final:
|
||||
|
||||
if(ms->tyre_diameter_config != NULL)
|
||||
{
|
||||
free(ms->tyre_diameter_config);
|
||||
}
|
||||
monocoquesettingsfree(ms);
|
||||
free(ms);
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue