aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Evans <aevans@nicira.com>2011-06-30 18:08:59 -0700
committerAndrew Evans <aevans@nicira.com>2011-07-01 10:38:35 -0700
commit72ba2ed371ae593b6fda1d196c31d7dd408a6a1c (patch)
tree53a750844787a83d8c47370bcb6d3b1640d2e7fa
parent5d27908667cfa34f7786fdc88e9e09078453637a (diff)
connmgr: Free controller info in the same module where it's allocated.
Make ofproto_free_ofproto_controller_info() just a passthrough to connmgr_free_controller_info() so the allocation and freeing of memory in the controller info structure is done in the same place.
-rw-r--r--ofproto/connmgr.c15
-rw-r--r--ofproto/connmgr.h1
-rw-r--r--ofproto/ofproto.c11
3 files changed, 17 insertions, 10 deletions
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 7c043a4a..7776c889 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -416,6 +416,21 @@ connmgr_get_controller_info(struct connmgr *mgr, struct shash *info)
}
}
+void
+connmgr_free_controller_info(struct shash *info)
+{
+ struct shash_node *node;
+
+ SHASH_FOR_EACH (node, info) {
+ struct ofproto_controller_info *cinfo = node->data;
+ while (cinfo->pairs.n) {
+ free((char *) cinfo->pairs.values[--cinfo->pairs.n]);
+ }
+ free(cinfo);
+ }
+ shash_destroy(info);
+}
+
/* Changes 'mgr''s set of controllers to the 'n_controllers' controllers in
* 'controllers'. */
void
diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h
index 58b1ae3f..31416a1f 100644
--- a/ofproto/connmgr.h
+++ b/ofproto/connmgr.h
@@ -66,6 +66,7 @@ void connmgr_retry(struct connmgr *);
/* OpenFlow configuration. */
bool connmgr_has_controllers(const struct connmgr *);
void connmgr_get_controller_info(struct connmgr *, struct shash *);
+void connmgr_free_controller_info(struct shash *);
void connmgr_set_controllers(struct connmgr *,
const struct ofproto_controller[], size_t n);
void connmgr_reconnect(const struct connmgr *);
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index efa3686e..ac243cf0 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -845,16 +845,7 @@ ofproto_get_ofproto_controller_info(const struct ofproto *ofproto,
void
ofproto_free_ofproto_controller_info(struct shash *info)
{
- struct shash_node *node;
-
- SHASH_FOR_EACH (node, info) {
- struct ofproto_controller_info *cinfo = node->data;
- while (cinfo->pairs.n) {
- free((char *) cinfo->pairs.values[--cinfo->pairs.n]);
- }
- free(cinfo);
- }
- shash_destroy(info);
+ connmgr_free_controller_info(info);
}
/* Makes a deep copy of 'old' into 'port'. */