From eaf58ba906129ecaf61ff21ad9263e12bd8931cb Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 21 Jun 2019 08:25:42 +0200 Subject: [PATCH] lib: use MTYPE_STATIC Signed-off-by: David Lamparter --- bgpd/bgp_vty.c | 8 -------- lib/command.c | 2 +- lib/command.h | 1 - lib/frr_pthread.c | 4 ++-- lib/frr_pthread.h | 3 --- lib/hash.c | 4 ++-- lib/hash.h | 3 --- lib/if.c | 2 +- lib/if.h | 1 - lib/table.c | 2 +- lib/table.h | 1 - lib/yang.c | 4 ++-- lib/yang.h | 3 --- ripngd/ripng_interface.c | 6 ++++-- 14 files changed, 13 insertions(+), 31 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 6cbb9af50e..22e9469a73 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7722,14 +7722,6 @@ DEFUN (show_bgp_memory, count * sizeof(struct peer_group))); /* Other */ - if ((count = mtype_stats_alloc(MTYPE_HASH))) - vty_out(vty, "%ld hash tables, using %s of memory\n", count, - mtype_memstr(memstrbuf, sizeof(memstrbuf), - count * sizeof(struct hash))); - if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) - vty_out(vty, "%ld hash buckets, using %s of memory\n", count, - mtype_memstr(memstrbuf, sizeof(memstrbuf), - count * sizeof(struct hash_bucket))); if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) vty_out(vty, "%ld compiled regexes, using %s of memory\n", count, mtype_memstr(memstrbuf, sizeof(memstrbuf), diff --git a/lib/command.c b/lib/command.c index eb7ee52336..f257c7d0f9 100644 --- a/lib/command.c +++ b/lib/command.c @@ -48,7 +48,7 @@ #include "lib_errors.h" #include "northbound_cli.h" -DEFINE_MTYPE(LIB, HOST, "Host config") +DEFINE_MTYPE_STATIC(LIB, HOST, "Host config") DEFINE_MTYPE(LIB, COMPLETION, "Completion item") #define item(x) \ diff --git a/lib/command.h b/lib/command.h index cc4c5d52f2..fd8b56d62e 100644 --- a/lib/command.h +++ b/lib/command.h @@ -34,7 +34,6 @@ extern "C" { #endif -DECLARE_MTYPE(HOST) DECLARE_MTYPE(COMPLETION) /* diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c index 2a18e5cfc6..e588571c01 100644 --- a/lib/frr_pthread.c +++ b/lib/frr_pthread.c @@ -28,8 +28,8 @@ #include "memory.h" #include "linklist.h" -DEFINE_MTYPE(LIB, FRR_PTHREAD, "FRR POSIX Thread"); -DEFINE_MTYPE(LIB, PTHREAD_PRIM, "POSIX synchronization primitives"); +DEFINE_MTYPE_STATIC(LIB, FRR_PTHREAD, "FRR POSIX Thread") +DEFINE_MTYPE_STATIC(LIB, PTHREAD_PRIM, "POSIX sync primitives") /* default frr_pthread start/stop routine prototypes */ static void *fpt_run(void *arg); diff --git a/lib/frr_pthread.h b/lib/frr_pthread.h index 9bc7b94033..3afe7ba966 100644 --- a/lib/frr_pthread.h +++ b/lib/frr_pthread.h @@ -29,9 +29,6 @@ extern "C" { #endif -DECLARE_MTYPE(FRR_PTHREAD); -DECLARE_MTYPE(PTHREAD_PRIM); - #define OS_THREAD_NAMELEN 16 struct frr_pthread; diff --git a/lib/hash.c b/lib/hash.c index fad7de5138..9d9d39702e 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -29,8 +29,8 @@ #include "command.h" #include "libfrr.h" -DEFINE_MTYPE(LIB, HASH, "Hash") -DEFINE_MTYPE(LIB, HASH_BACKET, "Hash Bucket") +DEFINE_MTYPE_STATIC(LIB, HASH, "Hash") +DEFINE_MTYPE_STATIC(LIB, HASH_BACKET, "Hash Bucket") DEFINE_MTYPE_STATIC(LIB, HASH_INDEX, "Hash Index") static pthread_mutex_t _hashes_mtx = PTHREAD_MUTEX_INITIALIZER; diff --git a/lib/hash.h b/lib/hash.h index c56a98d50c..7b3372d433 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -28,9 +28,6 @@ extern "C" { #endif -DECLARE_MTYPE(HASH) -DECLARE_MTYPE(HASH_BACKET) - /* Default hash table size. */ #define HASH_INITIAL_SIZE 256 /* Expansion threshold */ diff --git a/lib/if.c b/lib/if.c index 4314252d76..f7a167f251 100644 --- a/lib/if.c +++ b/lib/if.c @@ -39,7 +39,7 @@ #include "lib/if_clippy.c" #endif -DEFINE_MTYPE(LIB, IF, "Interface") +DEFINE_MTYPE_STATIC(LIB, IF, "Interface") DEFINE_MTYPE_STATIC(LIB, CONNECTED, "Connected") DEFINE_MTYPE_STATIC(LIB, NBR_CONNECTED, "Neighbor Connected") DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label") diff --git a/lib/if.h b/lib/if.h index 2dc1a7b2de..603c9c3780 100644 --- a/lib/if.h +++ b/lib/if.h @@ -31,7 +31,6 @@ extern "C" { #endif -DECLARE_MTYPE(IF) DECLARE_MTYPE(CONNECTED_LABEL) /* Interface link-layer type, if known. Derived from: diff --git a/lib/table.c b/lib/table.c index 728615c776..1a89a95f4f 100644 --- a/lib/table.c +++ b/lib/table.c @@ -28,7 +28,7 @@ #include "memory.h" #include "sockunion.h" -DEFINE_MTYPE(LIB, ROUTE_TABLE, "Route table") +DEFINE_MTYPE_STATIC(LIB, ROUTE_TABLE, "Route table") DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node") static void route_table_free(struct route_table *); diff --git a/lib/table.h b/lib/table.h index eefd992546..57b65ac4ba 100644 --- a/lib/table.h +++ b/lib/table.h @@ -31,7 +31,6 @@ extern "C" { #endif -DECLARE_MTYPE(ROUTE_TABLE) DECLARE_MTYPE(ROUTE_NODE) /* diff --git a/lib/yang.c b/lib/yang.c index 2f9a9aa5a3..674f3610d6 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -27,8 +27,8 @@ #include -DEFINE_MTYPE(LIB, YANG_MODULE, "YANG module") -DEFINE_MTYPE(LIB, YANG_DATA, "YANG data structure") +DEFINE_MTYPE_STATIC(LIB, YANG_MODULE, "YANG module") +DEFINE_MTYPE_STATIC(LIB, YANG_DATA, "YANG data structure") /* libyang container. */ struct ly_ctx *ly_native_ctx; diff --git a/lib/yang.h b/lib/yang.h index 6f8c84ab64..322c74c76a 100644 --- a/lib/yang.h +++ b/lib/yang.h @@ -33,9 +33,6 @@ extern "C" { #endif -DECLARE_MTYPE(YANG_MODULE) -DECLARE_MTYPE(YANG_DATA) - /* Maximum XPath length. */ #define XPATH_MAXLEN 256 diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index d83f4d2791..49ed13a2c2 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -49,6 +49,8 @@ #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP #endif +DEFINE_MTYPE_STATIC(RIPNGD, RIPNG_IF, "ripng interface") + /* Static utility function. */ static void ripng_enable_apply(struct interface *); static void ripng_passive_interface_apply(struct interface *); @@ -913,7 +915,7 @@ static struct ripng_interface *ri_new(void) { struct ripng_interface *ri; - ri = XCALLOC(MTYPE_IF, sizeof(struct ripng_interface)); + ri = XCALLOC(MTYPE_RIPNG_IF, sizeof(struct ripng_interface)); /* Set default split-horizon behavior. If the interface is Frame Relay or SMDS is enabled, the default value for split-horizon is @@ -950,7 +952,7 @@ static int ripng_if_new_hook(struct interface *ifp) /* Called when interface structure deleted. */ static int ripng_if_delete_hook(struct interface *ifp) { - XFREE(MTYPE_IF, ifp->info); + XFREE(MTYPE_RIPNG_IF, ifp->info); ifp->info = NULL; return 0; } -- 2.39.5