Skip to content

Commit

Permalink
Follow-up to preceding commit 0619a3a : the array of NORAD numbers sh…
Browse files Browse the repository at this point in the history
…ould be freed at shutdown. With this, Valgrind confirms that all memory has been properly freed.
  • Loading branch information
Bill-Gray committed Feb 21, 2024
1 parent 0619a3a commit beddf05
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sat_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ static int add_tle_to_obs( object_t *objects, const size_t n_objects,
const double max_revs_per_day)
{
char line0[100], line1[100], line2[100];
FILE *tle_file = fopen( tle_file_name, "rb");
FILE *tle_file;
int rval = 0, n_tles_found = 0;
bool check_updates = true;
bool look_for_tles = true;
Expand All @@ -1053,6 +1053,14 @@ static int add_tle_to_obs( object_t *objects, const size_t n_objects,
static int *norad_ids = NULL;
static size_t n_norad_ids = 0;

if( !tle_file_name) /* flag to free internal memory at shutdown */
{
if( norad_ids)
free( norad_ids);
n_norad_ids = 0;
return( 0);
}
tle_file = fopen( tle_file_name, "rb");
if( !tle_file)
{
#ifdef ON_LINE_VERSION
Expand Down Expand Up @@ -1759,6 +1767,7 @@ int main( const int argc, const char **argv)
free( objects[i].matches);
free( objects);
get_station_code_data( NULL, NULL);
add_tle_to_obs( NULL, 0, NULL, 0., 0.);
printf( "\n%.1f seconds elapsed\n", (double)clock( ) / (double)CLOCKS_PER_SEC);
return( rval);
} /* End of main() */

0 comments on commit beddf05

Please sign in to comment.