Deep Cleaning ADL, NPL
diff --git a/nlsr.c b/nlsr.c
index b3816b5..37ac91e 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -1084,9 +1084,12 @@
 	destroy_faces_for_nbrs();
 	
 	/* Destroying every hash table attached to each neighbor in ADL before destorying ADL */	
-	hashtb_destroy(&nlsr->adl);
-	hashtb_destroy(&nlsr->npl);	
-	hashtb_destroy(&nlsr->pit_alsa);
+	//hashtb_destroy(&nlsr->adl);
+	destroy_adl();
+	//hashtb_destroy(&nlsr->npl);
+	destroy_npl();
+		
+	//hashtb_destroy(&nlsr->pit_alsa);
 	hashtb_destroy(&nlsr->lsdb->name_lsdb);
 	hashtb_destroy(&nlsr->lsdb->adj_lsdb);
 	hashtb_destroy(&nlsr->lsdb->cor_lsdb);
@@ -1197,7 +1200,7 @@
 
 	nlsr->adl=hashtb_create(sizeof(struct ndn_neighbor), NULL);
 	nlsr->npl = hashtb_create(sizeof(struct name_prefix_list_entry), NULL);
-	nlsr->pit_alsa = hashtb_create(sizeof(struct pending_interest), NULL);
+	//nlsr->pit_alsa = hashtb_create(sizeof(struct pending_interest), NULL);
 	nlsr->npt = hashtb_create(sizeof(struct npt_entry), NULL);
 	nlsr->routing_table = hashtb_create(sizeof(struct routing_table_entry), NULL);
 
diff --git a/nlsr.h b/nlsr.h
index 681973b..2e33371 100644
--- a/nlsr.h
+++ b/nlsr.h
@@ -61,7 +61,7 @@
 
 	struct hashtb *adl;
 	struct hashtb *npl;
-	struct hashtb *pit_alsa;
+	//struct hashtb *pit_alsa;
 	struct hashtb *map;
 	struct hashtb *rev_map;
 	struct hashtb *npt;
diff --git a/nlsr_adl.c b/nlsr_adl.c
index 6076f89..3a68ce1 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -399,11 +399,13 @@
 	if (res == HT_OLD_ENTRY)
 	{
 		struct ndn_neighbor *nbr=e->data;
-		free(nbr->neighbor->name);
+		/*free(nbr->neighbor->name);
 		free(nbr->neighbor);
 		free(nbr->last_lsdb_version);
 		free(nbr->last_info_version);
 		free(nbr->ip_address);
+		*/
+		destroy_nbr_component(nbr);
 		hashtb_delete(e);
 			
 	}
@@ -724,3 +726,45 @@
 }
 
 
+void
+destroy_nbr_component(struct ndn_neighbor *nbr)
+{
+	if ( nbr->neighbor->name )
+		free(nbr->neighbor->name);
+	if ( nbr->neighbor )
+		free(nbr->neighbor);
+	if ( nbr->last_lsdb_version)
+		free(nbr->last_lsdb_version);
+	if ( nbr->last_info_version)
+		free(nbr->last_info_version);
+	if ( nbr->ip_address)
+		free(nbr->ip_address);
+}
+
+void
+destroy_adl(void)
+{	
+	int i, adl_element;
+	struct ndn_neighbor *nbr;
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = ⅇ
+    	
+    	hashtb_start(nlsr->adl, e);
+	adl_element=hashtb_n(nlsr->adl);
+
+	for(i=0;i<adl_element;i++)
+	{
+		nbr=e->data;
+		destroy_nbr_component(nbr);
+		hashtb_next(e);		
+	}
+
+	hashtb_end(e);
+	
+	if( nlsr->adl )
+		hashtb_destroy(&nlsr->adl);
+
+}
+
+
diff --git a/nlsr_adl.h b/nlsr_adl.h
index 884ae22..c3bdac7 100644
--- a/nlsr_adl.h
+++ b/nlsr_adl.h
@@ -53,4 +53,6 @@
 void update_face_to_adl_for_nbr(char *nbr, int face);
 
 void get_host_name_from_command_string(struct name_prefix *name_part,char *nbr_name_uri, int offset);
+void destroy_nbr_component(struct ndn_neighbor *nbr);
+void destroy_adl(void);
 #endif
diff --git a/nlsr_npl.c b/nlsr_npl.c
index a2e2271..5c36699 100644
--- a/nlsr_npl.c
+++ b/nlsr_npl.c
@@ -22,12 +22,11 @@
 #include "utility.h"
 
 
+
 void 
 add_name_to_npl(struct name_prefix *np)
 {
-	struct name_prefix_list_entry *npe=(struct name_prefix_list_entry *)malloc(sizeof(struct name_prefix_list_entry));
-	//struct name_prefix *hnp=(struct name_prefix *)malloc(sizeof(struct name_prefix )); //free
-
+	struct name_prefix_list_entry *npe;
 	struct hashtb_enumerator ee;
     	struct hashtb_enumerator *e = &ee; 	
     	int res;
@@ -38,15 +37,11 @@
 	if(res == HT_NEW_ENTRY)
 	{   
 		npe=e->data;
-		npe->np=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
+		npe->np=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
 		npe->np->length=np->length;
-		npe->np->name=(char *)malloc(np->length);
+		npe->np->name=(char *)calloc(np->length,sizeof(char));
 		memcpy(npe->np->name,np->name,np->length);
 		npe->name_lsa_id=0;
-		//hnp = e->data;
-		//hnp->length=np->length;
-		//hnp->name=(char *)malloc(np->length); //free
-		//memcpy(hnp->name,np->name,np->length);
 	}
     	
 	hashtb_end(e);
@@ -57,9 +52,6 @@
 does_name_exist_in_npl(struct name_prefix *np)
 {
 	int ret=0;
-
-	//struct name_prefix_entry *npe;
-
 	struct hashtb_enumerator ee;
     	struct hashtb_enumerator *e = &ee; 	
     	int res;
@@ -172,3 +164,36 @@
 	hashtb_end(e);
 }
 
+void
+destroy_npl_entry_component(struct name_prefix_list_entry *npe)
+{
+	if (npe->np->name)
+		free(npe->np->name);
+	if(npe->np)
+		free(npe->np);
+}
+
+void
+destroy_npl(void)
+{
+	int i, npl_element;
+	struct name_prefix_list_entry *npe;
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+    	
+    	hashtb_start(nlsr->npl, e);
+	npl_element=hashtb_n(nlsr->npl);
+
+	for(i=0;i<npl_element;i++)
+	{
+		npe=e->data;
+		destroy_npl_entry_component(npe);
+		hashtb_next(e);		
+	}
+
+	hashtb_end(e);
+
+	if ( nlsr->npl)
+		hashtb_destroy(&nlsr->npl);
+}
diff --git a/nlsr_npl.h b/nlsr_npl.h
index 4fce119..865bfcd 100644
--- a/nlsr_npl.h
+++ b/nlsr_npl.h
@@ -12,4 +12,6 @@
 int does_name_exist_in_npl(struct name_prefix *np);
 void update_nlsa_id_for_name_in_npl(struct name_prefix *np, long int nlsa_id);
 long int get_lsa_id_from_npl(struct name_prefix *np);
+void destroy_npl(void);
+void destroy_npl_entry_component(struct name_prefix_list_entry *npe);
 #endif