mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-12 16:57:23 -05:00
Fix minor memory leak on timestr;
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ examples
|
||||
*.bin
|
||||
*.ans
|
||||
*.patch
|
||||
*.zip
|
||||
@@ -396,6 +396,8 @@ void openMbeOutFile (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
int i, j;
|
||||
char ext[5];
|
||||
char * timestr; //add timestr here, so we can assign it and also free it to prevent memory leak
|
||||
timestr = getTimeF();
|
||||
|
||||
//phase 1 and provoice
|
||||
if ( (state->synctype == 0) || (state->synctype == 1) || (state->synctype == 14) || (state->synctype == 15) )
|
||||
@@ -421,7 +423,7 @@ void openMbeOutFile (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
state->tgcount = 0;
|
||||
|
||||
sprintf (opts->mbe_out_file, "%s %s S1%s", getDateF(), getTimeF(), ext);
|
||||
sprintf (opts->mbe_out_file, "%s %s S1%s", getDateF(), timestr, ext);
|
||||
|
||||
sprintf (opts->mbe_out_path, "%s%s", opts->mbe_out_dir, opts->mbe_out_file);
|
||||
|
||||
@@ -436,6 +438,7 @@ void openMbeOutFile (dsd_opts * opts, dsd_state * state)
|
||||
fprintf (opts->mbe_out_f, "%s", ext);
|
||||
|
||||
fflush (opts->mbe_out_f);
|
||||
free (timestr); //free allocated memory to prevent memory leak
|
||||
}
|
||||
|
||||
void openMbeOutFileR (dsd_opts * opts, dsd_state * state)
|
||||
@@ -443,6 +446,8 @@ void openMbeOutFileR (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
int i, j;
|
||||
char ext[5];
|
||||
char * timestr; //add timestr here, so we can assign it and also free it to prevent memory leak
|
||||
timestr = getTimeF();
|
||||
|
||||
//phase 1 and provoice
|
||||
if ( (state->synctype == 0) || (state->synctype == 1) || (state->synctype == 14) || (state->synctype == 15) )
|
||||
@@ -468,7 +473,7 @@ void openMbeOutFileR (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
state->tgcount = 0;
|
||||
|
||||
sprintf (opts->mbe_out_fileR, "%s %s S2%s", getDateF(), getTimeF(), ext);
|
||||
sprintf (opts->mbe_out_fileR, "%s %s S2%s", getDateF(), timestr, ext);
|
||||
|
||||
sprintf (opts->mbe_out_path, "%s%s", opts->mbe_out_dir, opts->mbe_out_fileR);
|
||||
|
||||
@@ -483,6 +488,7 @@ void openMbeOutFileR (dsd_opts * opts, dsd_state * state)
|
||||
fprintf (opts->mbe_out_fR, "%s", ext);
|
||||
|
||||
fflush (opts->mbe_out_fR);
|
||||
free (timestr); //free allocated memory to prevent memory leak
|
||||
}
|
||||
|
||||
void openWavOutFile (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
@@ -1853,7 +1853,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
|
||||
//fix location of this statement to inside the if statement and add conditions
|
||||
if (opts->audio_in_type == 3) //open rtl input if it is the specified input method
|
||||
{
|
||||
ncursesPrinter (opts, state); //run one rep to clear menu boxes out
|
||||
// ncursesPrinter (opts, state); //not sure why this was placed here originally, but causes a double free core dump when calling free(timestr)
|
||||
#ifdef USE_RTLSDR
|
||||
if (opts->rtl_started == 0)
|
||||
{
|
||||
@@ -4353,6 +4353,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
//so probably just write a function to handle c input, and when c = certain values
|
||||
//needing an entry box, then stop all of those
|
||||
|
||||
//allocated memory pointer needs to be free'd each time
|
||||
//if issues arise, just delete this line.
|
||||
//TODO: Redo this in edacs and file, making a seperate char * timestr instead of calling GetTime
|
||||
//directly from the sprintf command
|
||||
free (timestr);
|
||||
|
||||
} //end ncursesPrinter
|
||||
|
||||
void ncursesClose ()
|
||||
|
||||
@@ -297,6 +297,9 @@ void edacs(dsd_opts * opts, dsd_state * state)
|
||||
unsigned int netcmd = 0xF3; //using for Networked Test
|
||||
UNUSED2(vcmd, idcmd);
|
||||
|
||||
char * timestr; //add timestr here, so we can assign it and also free it to prevent memory leak
|
||||
timestr = getTimeE();
|
||||
|
||||
state->edacs_vc_lcn = -1; //init on negative for ncurses and tuning
|
||||
|
||||
int i;
|
||||
@@ -512,7 +515,7 @@ void edacs(dsd_opts * opts, dsd_state * state)
|
||||
//openwav file and do per call right here, should probably check as well to make sure we have a valid trunking method active (rigctl, rtl)
|
||||
if (opts->dmr_stereo_wav == 1 && (opts->use_rigctl == 1 || opts->audio_in_type == 3))
|
||||
{
|
||||
sprintf (opts->wav_out_file, "./WAV/%s %s EDACS Site %lld TG %d SRC %d.wav", getDateE(), getTimeE(), state->edacs_site_id, group, source);
|
||||
sprintf (opts->wav_out_file, "./WAV/%s %s EDACS Site %lld TG %d SRC %d.wav", getDateE(), timestr, state->edacs_site_id, group, source);
|
||||
openWavOutFile (opts, state);
|
||||
// openWavOutFile48k (opts, state); //debug for testing analog wav only
|
||||
}
|
||||
@@ -671,7 +674,7 @@ void edacs(dsd_opts * opts, dsd_state * state)
|
||||
//openwav file and do per call right here
|
||||
if (opts->dmr_stereo_wav == 1 && (opts->use_rigctl == 1 || opts->audio_in_type == 3))
|
||||
{
|
||||
sprintf (opts->wav_out_file, "./WAV/%s %s EDACS Site %lld AFS %02d-%03d - %03d.wav", getDateE(), getTimeE(), state->edacs_site_id, a, fs, afs);
|
||||
sprintf (opts->wav_out_file, "./WAV/%s %s EDACS Site %lld AFS %02d-%03d - %03d.wav", getDateE(), timestr, state->edacs_site_id, a, fs, afs);
|
||||
if (command == 0xEF) openWavOutFile (opts, state); //digital
|
||||
if (command == 0xEE) openWavOutFile48k (opts, state); //analog at 48k
|
||||
}
|
||||
@@ -722,7 +725,7 @@ void edacs(dsd_opts * opts, dsd_state * state)
|
||||
}
|
||||
|
||||
ENDPV:
|
||||
|
||||
free (timestr); //free allocated memory to prevent memory leak
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user