diff options
author | paul <paul> | 2006-01-16 12:01:29 +0000 |
---|---|---|
committer | paul <paul> | 2006-01-16 12:01:29 +0000 |
commit | 8fdc32ab9a81cb80296d322346867c8c3d2b2b37 (patch) | |
tree | bed62ebe30b81035f9ee9f5f605c1f443ad01c25 /bgpd | |
parent | 02335429e8cf2afc191fd518a3b55564bf6e5b2c (diff) | |
download | quagga-8fdc32ab9a81cb80296d322346867c8c3d2b2b37.tar.bz2 quagga-8fdc32ab9a81cb80296d322346867c8c3d2b2b37.tar.xz |
[bgpd] add aspath_finish, static resource cleanup function.
2006-01-16 Paul Jakma <paul.jakma@sun.com>
* bgp_aspath.c:
(aspath_snmp_pathseg) move the static stream pointer out to
file scope, so it can be freed.
(aspath_finish) new function, free aspath resources.
* bgp_aspath.h: (aspath_finish) export.
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/ChangeLog | 4 | ||||
-rw-r--r-- | bgpd/bgp_aspath.c | 27 | ||||
-rw-r--r-- | bgpd/bgp_aspath.h | 1 |
3 files changed, 24 insertions, 8 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog index ece8c4bd..b555334b 100644 --- a/bgpd/ChangeLog +++ b/bgpd/ChangeLog @@ -7,6 +7,10 @@ (aspath_parse) aspath_hash_alloc dupes the entire aspath, including segments, but we forgot to free the temporary assegment. + (aspath_snmp_pathseg) move the static stream pointer out to + file scope, so it can be freed. + (aspath_finish) new function, free aspath resources. + * bgp_aspath.h: (aspath_finish) export. 2006-01-10 Juris Kalnins <juris@mt.lv> diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index a6b77bbb..e9a6d6a2 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -78,6 +78,9 @@ struct assegment_header /* Hash for aspath. This is the top level structure of AS path. */ struct hash *ashash; + +/* Stream for SNMP. See aspath_snmp_pathseg */ +static struct stream *snmp_stream; static inline as_t * assegment_data_new (int num) @@ -769,22 +772,21 @@ u_char * aspath_snmp_pathseg (struct aspath *as, size_t *varlen) { #define SNMP_PATHSEG_MAX 1024 - static struct stream *s = NULL; - - if (!s) - s = stream_new (SNMP_PATHSEG_MAX); + + if (!snmp_stream) + snmp_stream = stream_new (SNMP_PATHSEG_MAX); else - stream_reset (s); + stream_reset (snmp_stream); if (!as) { *varlen = 0; return NULL; } - aspath_put (s, as); + aspath_put (snmp_stream, as); - *varlen = stream_get_endp (s); - return stream_pnt(s); + *varlen = stream_get_endp (snmp_stream); + return stream_pnt(snmp_stream); } #define min(A,B) ((A) < (B) ? (A) : (B)) @@ -1488,6 +1490,15 @@ aspath_init (void) { ashash = hash_create_size (32767, aspath_key_make, aspath_cmp); } + +void +aspath_finish (void) +{ + hash_free (ashash); + + if (snmp_stream) + stream_free (snmp_stream); +} /* return and as path value */ const char * diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h index adf58517..7fa7f20b 100644 --- a/bgpd/bgp_aspath.h +++ b/bgpd/bgp_aspath.h @@ -60,6 +60,7 @@ struct aspath /* Prototypes. */ extern void aspath_init (void); +extern void aspath_finish (void); extern struct aspath *aspath_parse (struct stream *, size_t); extern struct aspath *aspath_dup (struct aspath *); extern struct aspath *aspath_aggregate (struct aspath *, struct aspath *); |