Skip to content

Commit

Permalink
'sat_id' : the (now removed) assert() was triggered when we went past…
Browse files Browse the repository at this point in the history
… 200 included TLEs. The array is now resized as needed.
  • Loading branch information
Bill-Gray committed Feb 21, 2024
1 parent 1438e1b commit 0619a3a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sat_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ typedef struct
#define TIME_EPSILON (1./86400.)
#define EARTH_MAJOR_AXIS 6378137.
#define EARTH_MINOR_AXIS 6356752.
#define is_power_of_two( X) (!((X) & ((X) - 1)))

/* For testing purposes, I sometimes want _only_ "my" TLEs (not the
'classified' or Space-Watch TLEs) to be used. This is invoked with -s. */
Expand Down Expand Up @@ -1049,7 +1050,7 @@ static int add_tle_to_obs( object_t *objects, const size_t n_objects,
bool look_for_tles = true;
static bool error_check_date_ranges = true;
const clock_t time_started = clock( );
static int norad_ids[200];
static int *norad_ids = NULL;
static size_t n_norad_ids = 0;

if( !tle_file)
Expand Down Expand Up @@ -1372,7 +1373,10 @@ static int add_tle_to_obs( object_t *objects, const size_t n_objects,
i++;
if( i == n_norad_ids || search_norad != norad_ids[i])
{ /* insert newly-found ID */
assert( n_norad_ids < sizeof( norad_ids) / sizeof( norad_ids[0]));
if( !n_norad_ids)
norad_ids = (int *)malloc( sizeof( int));
else if( is_power_of_two( n_norad_ids))
norad_ids = (int *)realloc( norad_ids, 2 * n_norad_ids * sizeof( int));
memmove( norad_ids + i + 1, norad_ids + i, (n_norad_ids - i) * sizeof( int));
norad_ids[i] = search_norad;
n_norad_ids++;
Expand Down

0 comments on commit 0619a3a

Please sign in to comment.