Freeing unfreed memory
diff --git a/nlsr-sync-0.0/nlsr_face.c b/nlsr-sync-0.0/nlsr_face.c
index 1d74b06..533fe9e 100644
--- a/nlsr-sync-0.0/nlsr_face.c
+++ b/nlsr-sync-0.0/nlsr_face.c
@@ -381,8 +381,7 @@
ccn_face_instance_destroy(&nfi);
ccn_charbuf_destroy(&prefix);
- //return nfi->faceid;
-
+
return faceid;
cleanup:
diff --git a/nlsr-sync-0.0/nlsr_sync.c b/nlsr-sync-0.0/nlsr_sync.c
index 289cf39..f3ad3c4 100644
--- a/nlsr-sync-0.0/nlsr_sync.c
+++ b/nlsr-sync-0.0/nlsr_sync.c
@@ -29,7 +29,8 @@
#include "nlsr_sync.h"
#include "nlsr_lsdb.h"
#include "utility.h"
-//test method
+
+
char *
hex_string(unsigned char *s, size_t l)
{
@@ -66,33 +67,31 @@
else
ccn_charbuf_append_string(uri, "(null)");
- //if ( nlsr->debugging )
- //printf("%s %s %s\n", ccn_charbuf_as_string(uri), hexL, hexR);
-
+
if ( nlsr->debugging )
printf("Response from sync in the name: %s \n",ccn_charbuf_as_string(uri));
fflush(stdout);
free(hexL);
free(hexR);
- ccn_charbuf_destroy(&uri);
+ //ccn_charbuf_destroy(&uri);
- //--Doing ourthing from here
+ //--Doing our thing from here
struct ccn_indexbuf cid={0};
struct ccn_indexbuf *components=&cid;
- ccn_name_split (name, components);
- ccn_name_chop(name,components,-3);
+ ccn_name_split (uri, components);
+ ccn_name_chop(uri,components,-3);
- process_content_from_sync(name,components);
+ process_content_from_sync(uri,components);
-
+ ccn_charbuf_destroy(&uri);
return(0);
}
-//test method
+
int
get_lsa_position(struct ccn_charbuf * ccnb, struct ccn_indexbuf *comps)
@@ -101,8 +100,7 @@
int res,i;
- int lsa_position=0; //Obaid: Hoque make it -1, 0 is also an index
- // I didn't change it as it might break the code.
+ int lsa_position=0;
int name_comps=(int)comps->n;
for(i=0;i<name_comps;i++)
@@ -129,10 +127,6 @@
int lsa_position=0;
int len=0;
- //lsa_position=get_lsa_position(interest_ccnb,interest_comps);
-
- //printf("LSA Position: %d \n",lsa_position);
-
struct ccn_indexbuf cid={0};
struct ccn_indexbuf *components=&cid;
@@ -140,7 +134,7 @@
ccn_name_from_uri(name,nlsr->slice_prefix);
ccn_name_split (name, components);
lsa_position=components->n-2;
- //printf("LSA Position from Slice Prefix Component: %d \n",(int)components->n-2);
+
ccn_charbuf_destroy(&name);
@@ -170,7 +164,8 @@
memcpy(name_part->name,neighbor,strlen(neighbor)+1);
name_part->length=strlen(neighbor)+1;
-
+ // Add 01/31/2013
+ free(neighbor);
}
void
@@ -222,7 +217,9 @@
memcpy(name_part->name,neighbor,strlen(neighbor)+1);
name_part->length=strlen(neighbor)+1;
-
+ // 01/31/2013
+ free(neighbor);
+ ccn_charbuf_destroy(&name);
}
@@ -286,7 +283,6 @@
res = ccn_resolve_version(nlsr->ccn, name, resolve_version, 500);
if (res >= 0) {
ccn_uri_append(resultbuf, name->buf, name->length, 1);
- //fprintf(stderr, "== %s\n",ccn_charbuf_as_string(resultbuf));
resultbuf->length = 0;
}
}
@@ -303,7 +299,6 @@
ccn_charbuf_destroy(&resultbuf);
ccn_charbuf_destroy(&templ);
ccn_charbuf_destroy(&name);
- //return (unsigned char *)ptr;
}
void
@@ -571,28 +566,10 @@
if (content_data != NULL)
free(content_data);
ccn_charbuf_destroy(&uri);
+ //01/31/2013
+ free(time_stamp);
}
-int
-sync_callback(struct ccns_name_closure *nc,
- struct ccn_charbuf *lhash,
- struct ccn_charbuf *rhash,
- struct ccn_charbuf *name)
-{
-
-
- struct ccn_indexbuf cid={0};
-
- struct ccn_indexbuf *components=&cid;
- ccn_name_split (name, components);
- ccn_name_chop(name,components,-3);
-
- process_content_from_sync(name,components);
-
- return(0);
-}
-
-
void
sync_monitor(char *topo_prefix, char *slice_prefix)
{
@@ -616,8 +593,11 @@
ccns_slice_set_topo_prefix(nlsr->slice, topo, prefix);
nlsr->closure->callback = &sync_cb;
- //nlsr->closure->callback = &sync_callback;
nlsr->ccns = ccns_open(nlsr->ccn, nlsr->slice, nlsr->closure, roothash, NULL);
+
+ //01/31/2013
+ ccn_charbuf_destroy(&prefix);
+ ccn_charbuf_destroy(&topo);
}
struct ccn_charbuf *
@@ -748,17 +728,14 @@
res = ccns_write_slice(nlsr->ccn, slice, slice_name);
- /*
-// Obaid: commenting out the following lines to resolve a bug.
-// If commenting them can resolve the issue, then we
-// need to call them before terminating the program.
+
+ //01/31/2013
ccns_slice_destroy(&slice);
ccn_charbuf_destroy(&prefix);
ccn_charbuf_destroy(&topo);
ccn_charbuf_destroy(&clause);
ccn_charbuf_destroy(&slice_name);
ccn_charbuf_destroy(&slice_uri);
-*/
return 0;
}