Memory Leak Reduction
diff --git a/nlsr.c b/nlsr.c
index dce1e8e..1b344ff 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -478,8 +478,8 @@
printf(" Wrong Command Format ( logdir /path/to/logdir/ )\n");
return;
}
- if ( nlsr->logDir)
- free(nlsr->logDir);
+ //if ( nlsr->logDir)
+ //free(nlsr->logDir);
nlsr->logDir=(char *)calloc(strlen(dir)+1,sizeof(char));
memcpy(nlsr->logDir,dir,strlen(dir)+1);
}
diff --git a/nlsr_adl.c b/nlsr_adl.c
index 2babc55..f93eba7 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -688,9 +688,10 @@
exit(1);
}
- struct ccn_indexbuf cid={0};
+ //struct ccn_indexbuf cid={0};
- struct ccn_indexbuf *components=&cid;
+ //struct ccn_indexbuf *components=&cid;
+ struct ccn_indexbuf *components=ccn_indexbuf_create();
ccn_name_split (name, components);
for(i=components->n-2;i> (0+offset);i--)
@@ -721,6 +722,7 @@
// 01/31/2013
free(neighbor);
ccn_charbuf_destroy(&name);
+ ccn_indexbuf_destroy(&components);
}
diff --git a/nlsr_lsdb.c b/nlsr_lsdb.c
index 4617096..8e4fe16 100644
--- a/nlsr_lsdb.c
+++ b/nlsr_lsdb.c
@@ -903,8 +903,8 @@
new_adj_lsa->no_link=adj_lsa->no_link;
- if(new_adj_lsa->body )
- free(new_adj_lsa->body);
+ //if(new_adj_lsa->body )
+ //free(new_adj_lsa->body);
new_adj_lsa->body=(char *)calloc(strlen(adj_lsa->body)+1,sizeof(char));
//memset(new_adj_lsa->body,0,strlen(adj_lsa->body)+1);
memcpy(new_adj_lsa->body,adj_lsa->body,strlen(adj_lsa->body)+1);
diff --git a/nlsr_route.c b/nlsr_route.c
index 2a25747..e84b0a7 100644
--- a/nlsr_route.c
+++ b/nlsr_route.c
@@ -50,9 +50,9 @@
print_routing_table();
print_npt();
- struct hashtb_param param_me = {0};
- nlsr->map = hashtb_create(sizeof(struct map_entry), ¶m_me);
- nlsr->rev_map = hashtb_create(sizeof(struct map_entry), ¶m_me);
+ //struct hashtb_param param_me = {0};
+ nlsr->map = hashtb_create(sizeof(struct map_entry), NULL);
+ nlsr->rev_map = hashtb_create(sizeof(struct map_entry), NULL);
make_map();
assign_mapping_number();
print_map();
diff --git a/nlsr_sync.c b/nlsr_sync.c
index 199b1df..f2d390b 100644
--- a/nlsr_sync.c
+++ b/nlsr_sync.c
@@ -124,8 +124,9 @@
int lsa_position=0;
//int len=0;
- struct ccn_indexbuf cid={0};
- struct ccn_indexbuf *components=&cid;
+ //struct ccn_indexbuf cid={0};
+ //struct ccn_indexbuf *components=&cid;
+ struct ccn_indexbuf *components=ccn_indexbuf_create();
struct ccn_charbuf *name=ccn_charbuf_create();
ccn_name_from_uri(name,nlsr->slice_prefix);
ccn_name_split (name, components);
@@ -147,6 +148,7 @@
ccn_charbuf_destroy(&temp1);
ccn_charbuf_destroy(&temp);
+ ccn_indexbuf_destroy(&components);
if ( nlsr->debugging )
printf("Name Part: %s \n",name_part->name);