bgpd: optimize aspath string representation and assegments handling
* bgp_aspath.h: Add str_len to struct aspath.
* bgp_aspath.c: Save the aspath string representation length and use it
instead of strlen().
(aspath_make_str_count) assign the string buffer directly for
consistency with the string length and change the return type to void.
(aspath_dup) use str_len and copy the string instead of calling
aspath_make_str_count().
(assegment_data_new) change from XCALLOC to XMALLOC. All users initialize
the memory before use.
(assegment_data_free) unused, removed.
(aspath_intern) check that there's always a ->str pointer.
(aspath_hash_alloc) reuse assegments and string representation instead of
copying them.
(aspath_parse) now aspath_hash_alloc does not dupes memory, free the
temporary structures only if the aspath it is in the hash.
(aspath_cmp_left) remove useless NULL initialization.
Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2 files changed