Free Some Unfreed Memory
diff --git a/nlsr.c b/nlsr.c
index ec250fa..7eadb85 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -563,8 +563,6 @@
free(nlsr->slice_prefix);
if ( slice_prefix[strlen(slice_prefix)-1] == '/' )
slice_prefix[strlen(slice_prefix)-1]='\0';
- //if( nlsr->slice_prefix)
- //free(nlsr->slice_prefix);
nlsr->slice_prefix=(char *)calloc(strlen(slice_prefix)+1,sizeof(char));
memcpy(nlsr->slice_prefix,slice_prefix,strlen(slice_prefix)+1);
printf("Slice prefix: %s \n",nlsr->slice_prefix);
@@ -1222,6 +1220,12 @@
free(nlsr->site_name);
free(nlsr->router_name);
+
+
+ free(nlsr->slice_prefix);
+ free(nlsr->topo_prefix);
+ free(nlsr->logDir);
+
if ( nlsr->debugging )
{
printf("Finished freeing allocated memory\n");
diff --git a/nlsr_adl.c b/nlsr_adl.c
index f93eba7..4eedf40 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -681,7 +681,6 @@
size_t comp_size;
struct ccn_charbuf *name=ccn_charbuf_create();
- name = ccn_charbuf_create();
res = ccn_name_from_uri(name,nbr_name_uri);
if (res < 0) {
fprintf(stderr, "Bad ccn URI: %s\n", nbr_name_uri);
diff --git a/nlsr_ndn.c b/nlsr_ndn.c
index a0967a1..3a724d5 100644
--- a/nlsr_ndn.c
+++ b/nlsr_ndn.c
@@ -134,7 +134,6 @@
len++;
char *neighbor=(char *)calloc(len,sizeof(char));
- //memset(neighbor,0,len);
for(i=nlsr_position+3+offset; i<info->interest_comps->n-1;i++)
{
@@ -145,8 +144,7 @@
}
- lsaId->name=(char *)malloc(strlen(neighbor)+1);
- memset(lsaId->name,0,strlen(neighbor)+1);
+ lsaId->name=(char *)calloc(strlen(neighbor)+1,sizeof(char));
memcpy(lsaId->name,neighbor,strlen(neighbor)+1);
lsaId->length=strlen(neighbor)+1;
@@ -354,11 +352,10 @@
send_info_interest_to_neighbor(nbr);
}
- free(nbr);
- //free(raw_data);
- //ccn_charbuf_destroy(&sp.template_ccnb);
- //ccn_charbuf_destroy(&pubid);
- //ccn_charbuf_destroy(&pubkey);
+ if ( nbr->name != NULL )
+ free(nbr->name);
+ if ( nbr != NULL )
+ free(nbr);
ccn_charbuf_destroy(&resultbuf);
}
@@ -573,8 +570,10 @@
}
*/
-
- free(nbr);
+ if ( nbr->name != NULL )
+ free(nbr->name);
+ if ( nbr != NULL )
+ free(nbr);
}
diff --git a/nlsr_npt.c b/nlsr_npt.c
index 00728cd..3f9f240 100644
--- a/nlsr_npt.c
+++ b/nlsr_npt.c
@@ -49,8 +49,7 @@
{
ne=e->data;
- ne->orig_router=(char *)malloc(strlen(orig_router)+1);
- memset(ne->orig_router,0,strlen(orig_router)+1);
+ ne->orig_router=(char *)calloc(strlen(orig_router)+1,sizeof(char));
memcpy(ne->orig_router,orig_router,strlen(orig_router)+1);