From 0549caf6fdaf371d272dee7df601cd5070bcfa54 Mon Sep 17 00:00:00 2001
From: joanvallve <jvallve@iri.upc.edu>
Date: Tue, 17 Mar 2020 09:44:10 +0100
Subject: [PATCH] =?UTF-8?q?codi=20inspiraci=C3=B3=20per=20a=20freenav?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/navigation.cpp | 43 ++++++++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/src/navigation.cpp b/src/navigation.cpp
index cfba893..ed095bc 100644
--- a/src/navigation.cpp
+++ b/src/navigation.cpp
@@ -41,23 +41,32 @@ void Navigation::freeNavigation()
 }
 
 void Navigation::clearNavigation()
-{  
-  nav_.eph =NULL;
-  nav_.geph=NULL;
-  nav_.seph=NULL;
-  nav_.peph=NULL;
-  nav_.pclk=NULL;
-  nav_.alm =NULL;
-  nav_.tec =NULL;
-  nav_.fcb =NULL;
-  nav_.n =nav_.nmax =0;
-  nav_.ng=nav_.ngmax=0;
-  nav_.ns=nav_.nsmax=0;
-  nav_.ne=nav_.nemax=0;
-  nav_.nc=nav_.ncmax=0;
-  nav_.na=nav_.namax=0;
-  nav_.nt=nav_.ntmax=0;
-  nav_.nf=nav_.nfmax=0;
+{
+    // inspire from RTKLIB:
+    //    if (opt&0x01) {free(nav->eph ); nav->eph =NULL; nav->n =nav->nmax =0;}
+    //    if (opt&0x02) {free(nav->geph); nav->geph=NULL; nav->ng=nav->ngmax=0;}
+    //    if (opt&0x04) {free(nav->seph); nav->seph=NULL; nav->ns=nav->nsmax=0;}
+    //    if (opt&0x08) {free(nav->peph); nav->peph=NULL; nav->ne=nav->nemax=0;}
+    //    if (opt&0x10) {free(nav->pclk); nav->pclk=NULL; nav->nc=nav->ncmax=0;}
+    //    if (opt&0x20) {free(nav->alm ); nav->alm =NULL; nav->na=nav->namax=0;}
+    //    if (opt&0x40) {free(nav->tec ); nav->tec =NULL; nav->nt=nav->ntmax=0;}
+    //    if (opt&0x80) {free(nav->fcb ); nav->fcb =NULL; nav->nf=nav->nfmax=0;}
+    nav_.eph =NULL;
+    nav_.geph=NULL;
+    nav_.seph=NULL;
+    nav_.peph=NULL;
+    nav_.pclk=NULL;
+    nav_.alm =NULL;
+    nav_.tec =NULL;
+    nav_.fcb =NULL;
+    nav_.n =nav_.nmax =0;
+    nav_.ng=nav_.ngmax=0;
+    nav_.ns=nav_.nsmax=0;
+    nav_.ne=nav_.nemax=0;
+    nav_.nc=nav_.ncmax=0;
+    nav_.na=nav_.namax=0;
+    nav_.nt=nav_.ntmax=0;
+    nav_.nf=nav_.nfmax=0;
 }
 
 void Navigation::setNavigation(nav_t _nav)
-- 
GitLab