1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-23 13:33:15 +00:00

Remove unused functions with defects in memory management

This commit is contained in:
Carles Fernandez 2019-08-14 20:06:48 +02:00
parent c52a3dd4b5
commit d298bdf0a9
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 12 additions and 164 deletions

View File

@ -625,161 +625,6 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta)
}
/* add satellite fcb ---------------------------------------------------------*/
int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat,
const double *bias, const double *std)
{
fcbd_t *nav_fcb;
int i;
int j;
if (nav->nf > 0 && fabs(timediff(ts, nav->fcb[nav->nf - 1].ts)) <= 1e-3)
{
for (i = 0; i < 3; i++)
{
nav->fcb[nav->nf - 1].bias[sat - 1][i] = bias[i];
nav->fcb[nav->nf - 1].std[sat - 1][i] = std[i];
}
return 1;
}
if (nav->nf >= nav->nfmax)
{
nav->nfmax = nav->nfmax <= 0 ? 2048 : nav->nfmax * 2;
if (!(nav_fcb = static_cast<fcbd_t *>(realloc(nav->fcb, sizeof(fcbd_t) * nav->nfmax))))
{
free(nav->fcb);
nav->nf = nav->nfmax = 0;
return 0;
}
nav->fcb = nav_fcb;
}
for (i = 0; i < MAXSAT; i++)
{
for (j = 0; j < 3; j++)
{
nav->fcb[nav->nf].bias[i][j] = nav->fcb[nav->nf].std[i][j] = 0.0;
}
}
for (i = 0; i < 3; i++)
{
nav->fcb[nav->nf].bias[sat - 1][i] = bias[i];
nav->fcb[nav->nf].std[sat - 1][i] = std[i];
}
nav->fcb[nav->nf].ts = ts;
nav->fcb[nav->nf++].te = te;
return 1;
}
/* read satellite fcb file ---------------------------------------------------*/
int readfcbf(const char *file, nav_t *nav)
{
FILE *fp;
gtime_t ts;
gtime_t te;
double ep1[6];
double ep2[6];
double bias[3] = {};
double std[3] = {};
char buff[1024];
char str[32];
char *p;
int sat;
trace(3, "readfcbf: file=%s\n", file);
if (!(fp = fopen(file, "re")))
{
trace(2, "fcb parameters file open error: %s\n", file);
return 0;
}
while (fgets(buff, sizeof(buff), fp))
{
if ((p = strchr(buff, '#')))
{
*p = '\0';
}
if (sscanf(buff,
"%lf/%lf/%lf %lf:%lf:%lf %lf/%lf/%lf %lf:%lf:%lf %s"
"%lf %lf %lf %lf %lf %lf",
ep1, ep1 + 1, ep1 + 2, ep1 + 3, ep1 + 4, ep1 + 5,
ep2, ep2 + 1, ep2 + 2, ep2 + 3, ep2 + 4, ep2 + 5, str, bias, std, bias + 1, std + 1,
bias + 2, std + 2) < 17)
{
continue;
}
if (!(sat = satid2no(str)))
{
continue;
}
ts = epoch2time(ep1);
te = epoch2time(ep2);
if (!addfcb(nav, ts, te, sat, bias, std))
{
fclose(fp);
return 0;
}
}
fclose(fp);
return 1;
}
/* compare satellite fcb -----------------------------------------------------*/
int cmpfcb(const void *p1, const void *p2)
{
auto *q1 = (fcbd_t *)p1;
auto *q2 = (fcbd_t *)p2;
double tt = timediff(q1->ts, q2->ts);
return tt < -1e-3 ? -1 : (tt > 1e-3 ? 1 : 0);
}
/* read satellite fcb data -----------------------------------------------------
* read satellite fractional cycle bias (dcb) parameters
* args : char *file I fcb parameters file (wild-card * expanded)
* nav_t *nav IO navigation data
* return : status (1:ok,0:error)
* notes : fcb data appended to navigation data
*-----------------------------------------------------------------------------*/
int readfcb(const char *file, nav_t *nav)
{
char *efiles[MAXEXFILE] = {};
int i;
int n;
trace(3, "readfcb : file=%s\n", file);
for (i = 0; i < MAXEXFILE; i++)
{
if (!(efiles[i] = static_cast<char *>(malloc(1024))))
{
for (i--; i >= 0; i--)
{
free(efiles[i]);
}
return 0;
}
}
n = expath(file, efiles, MAXEXFILE);
for (i = 0; i < n; i++)
{
readfcbf(efiles[i], nav);
}
for (i = 0; i < MAXEXFILE; i++)
{
free(efiles[i]);
}
if (nav->nf > 1)
{
qsort(nav->fcb, nav->nf, sizeof(fcbd_t), cmpfcb);
}
return 1;
}
/* polynomial interpolation by Neville's algorithm ---------------------------*/
double interppol(const double *x, double *y, int n)
{

View File

@ -72,27 +72,29 @@ const double EXTERR_CLK = 1e-3; /* extrapolation error for clock (m/s) */
const double EXTERR_EPH = 5e-7; /* extrapolation error for ephem (m/s^2) */
int code2sys(char code);
int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats,
double *bfact, char *tsys);
int addpeph(nav_t *nav, peph_t *peph);
void readsp3b(FILE *fp, char type, int *sats, int ns, const double *bfact,
char *tsys, int index, int opt, nav_t *nav);
int cmppeph(const void *p1, const void *p2);
void combpeph(nav_t *nav, int opt);
void readsp3(const char *file, nav_t *nav, int opt);
int readsap(const char *file, gtime_t time, nav_t *nav);
int readdcbf(const char *file, nav_t *nav, const sta_t *sta);
int readdcb(const char *file, nav_t *nav, const sta_t *sta);
int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat,
const double *bias, const double *std);
int readfcbf(const char *file, nav_t *nav);
int readdcb(const char *file, nav_t *nav, const sta_t *sta);
int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat,
const double *bias, const double *std);
int readfcbf(const char *file, nav_t *nav);
int cmpfcb(const void *p1, const void *p2);
int readfcb(const char *file, nav_t *nav);
double interppol(const double *x, double *y, int n);
int pephpos(gtime_t time, int sat, const nav_t *nav, double *rs,
double *dts, double *vare, double *varc);
@ -101,6 +103,7 @@ int pephclk(gtime_t time, int sat, const nav_t *nav, double *dts,
void satantoff(gtime_t time, const double *rs, int sat, const nav_t *nav,
double *dant);
int peph2pos(gtime_t time, int sat, const nav_t *nav, int opt,
double *rs, double *dts, double *var);