[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] fix a memory leak on exit in routerlist.c
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv5631/src/or
Modified Files:
routerlist.c
Log Message:
fix a memory leak on exit in routerlist.c
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.318
retrieving revision 1.319
diff -u -d -r1.318 -r1.319
--- routerlist.c 30 Sep 2005 20:04:55 -0000 1.318
+++ routerlist.c 30 Sep 2005 21:04:52 -0000 1.319
@@ -30,6 +30,7 @@
static int router_nickname_is_in_list(routerinfo_t *router, const char *list);
static int router_nickname_matches(routerinfo_t *router, const char *nickname);
static void routerstatus_list_update_from_networkstatus(time_t now);
+static void local_routerstatus_free(local_routerstatus_t *rs);
/****************************************************************************/
@@ -1016,6 +1017,12 @@
smartlist_free(networkstatus_list);
networkstatus_list = NULL;
}
+ if (routerstatus_list) {
+ SMARTLIST_FOREACH(routerstatus_list, local_routerstatus_t *, rs,
+ local_routerstatus_free(rs));
+ smartlist_free(routerstatus_list);
+ routerstatus_list = NULL;
+ }
}
/** Free all storage held by the routerstatus object <b>rs</b>. */
@@ -1025,6 +1032,13 @@
tor_free(rs);
}
+/** Free all storage held by the local_routerstatus object <b>rs</b>. */
+static void
+local_routerstatus_free(local_routerstatus_t *rs)
+{
+ tor_free(rs);
+}
+
/** Free all storage held by the networkstatus object <b>ns</b>. */
void
networkstatus_free(networkstatus_t *ns)
@@ -2293,8 +2307,8 @@
rs_out->status.is_valid = n_valid > n_statuses/2;
rs_out->status.is_running = n_running > n_recent/2;
}
- SMARTLIST_FOREACH(routerstatus_list, routerstatus_t *, rs,
- routerstatus_free(rs));
+ SMARTLIST_FOREACH(routerstatus_list, local_routerstatus_t *, rs,
+ local_routerstatus_free(rs));
smartlist_free(routerstatus_list);
routerstatus_list = result;