summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-08-18 14:13:29 -0700
committerPaul Jakma <paul@quagga.net>2009-06-12 17:07:49 +0100
commit393deb9bd663361e6b110d579a8b1d4c22667068 (patch)
treee93ebf2f57bf92ff7a9cd045764b3cdbb99a07e5 /bgpd
parent3453a7122c1d585ad789ed0f63deb90cc5e89fae (diff)
[cleanup] Convert XMALLOC/memset to XCALLOC
Simple conversion of XMALLOC/memset to XCALLOC
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_aspath.c6
-rw-r--r--bgpd/bgp_attr.c8
-rw-r--r--bgpd/bgp_clist.c12
-rw-r--r--bgpd/bgp_filter.c12
-rw-r--r--bgpd/bgp_nexthop.c18
-rw-r--r--bgpd/bgp_route.c22
-rw-r--r--bgpd/bgp_routemap.c11
-rw-r--r--bgpd/bgp_table.c9
8 files changed, 21 insertions, 77 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index d0d621c2..5881abe2 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -322,11 +322,7 @@ assegment_normalise (struct assegment *head)
static struct aspath *
aspath_new (void)
{
- struct aspath *aspath;
-
- aspath = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
- memset (aspath, 0, sizeof (struct aspath));
- return aspath;
+ return XCALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
}
/* Free AS path structure. */
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index f38db414..5839d3fe 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -153,8 +153,7 @@ cluster_dup (struct cluster_list *cluster)
{
struct cluster_list *new;
- new = XMALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list));
- memset (new, 0, sizeof (struct cluster_list));
+ new = XCALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list));
new->length = cluster->length;
if (cluster->length)
@@ -1495,10 +1494,7 @@ bgp_attr_unknown (struct peer *peer, struct attr *attr, u_char flag,
/* Store transitive attribute to the end of attr->transit. */
if (! ((attre = bgp_attr_extra_get(attr))->transit) )
- {
- attre->transit = XMALLOC (MTYPE_TRANSIT, sizeof (struct transit));
- memset (attre->transit, 0, sizeof (struct transit));
- }
+ attre->transit = XCALLOC (MTYPE_TRANSIT, sizeof (struct transit));
transit = attre->transit;
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index f75fc55b..a8d8742f 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -51,11 +51,7 @@ community_list_master_lookup (struct community_list_handler *ch, int master)
static struct community_entry *
community_entry_new ()
{
- struct community_entry *new;
-
- new = XMALLOC (MTYPE_COMMUNITY_LIST_ENTRY, sizeof (struct community_entry));
- memset (new, 0, sizeof (struct community_entry));
- return new;
+ return XCALLOC (MTYPE_COMMUNITY_LIST_ENTRY, sizeof (struct community_entry));
}
/* Free community list entry. */
@@ -92,11 +88,7 @@ community_entry_free (struct community_entry *entry)
static struct community_list *
community_list_new ()
{
- struct community_list *new;
-
- new = XMALLOC (MTYPE_COMMUNITY_LIST, sizeof (struct community_list));
- memset (new, 0, sizeof (struct community_list));
- return new;
+ return XCALLOC (MTYPE_COMMUNITY_LIST, sizeof (struct community_list));
}
/* Free community-list. */
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index ab7f0703..eb4ff8ea 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -99,11 +99,7 @@ static struct as_list_master as_list_master =
static struct as_filter *
as_filter_new ()
{
- struct as_filter *new;
-
- new = XMALLOC (MTYPE_AS_FILTER, sizeof (struct as_filter));
- memset (new, 0, sizeof (struct as_filter));
- return new;
+ return XCALLOC (MTYPE_AS_FILTER, sizeof (struct as_filter));
}
/* Free allocated AS filter. */
@@ -179,11 +175,7 @@ as_list_lookup (const char *name)
static struct as_list *
as_list_new ()
{
- struct as_list *new;
-
- new = XMALLOC (MTYPE_AS_LIST, sizeof (struct as_list));
- memset (new, 0, sizeof (struct as_list));
- return new;
+ return XCALLOC (MTYPE_AS_LIST, sizeof (struct as_list));
}
static void
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 22e48db0..b2ee7f3b 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -98,11 +98,7 @@ bnc_nexthop_free (struct bgp_nexthop_cache *bnc)
static struct bgp_nexthop_cache *
bnc_new ()
{
- struct bgp_nexthop_cache *new;
-
- new = XMALLOC (MTYPE_BGP_NEXTHOP_CACHE, sizeof (struct bgp_nexthop_cache));
- memset (new, 0, sizeof (struct bgp_nexthop_cache));
- return new;
+ return XCALLOC (MTYPE_BGP_NEXTHOP_CACHE, sizeof (struct bgp_nexthop_cache));
}
static void
@@ -575,8 +571,7 @@ bgp_connected_add (struct connected *ifc)
}
else
{
- bc = XMALLOC (0, sizeof (struct bgp_connected_ref));
- memset (bc, 0, sizeof (struct bgp_connected_ref));
+ bc = XCALLOC (0, sizeof (struct bgp_connected_ref));
bc->refcnt = 1;
rn->info = bc;
}
@@ -601,8 +596,7 @@ bgp_connected_add (struct connected *ifc)
}
else
{
- bc = XMALLOC (0, sizeof (struct bgp_connected_ref));
- memset (bc, 0, sizeof (struct bgp_connected_ref));
+ bc = XCALLOC (0, sizeof (struct bgp_connected_ref));
bc->refcnt = 1;
rn->info = bc;
}
@@ -748,8 +742,7 @@ zlookup_read ()
for (i = 0; i < nexthop_num; i++)
{
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = stream_getc (s);
switch (nexthop->type)
{
@@ -858,8 +851,7 @@ zlookup_read_ipv6 ()
for (i = 0; i < nexthop_num; i++)
{
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = stream_getc (s);
switch (nexthop->type)
{
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 6b7828ca..5177dc07 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -129,12 +129,7 @@ bgp_info_extra_get (struct bgp_info *ri)
static struct bgp_info *
bgp_info_new ()
{
- struct bgp_info *new;
-
- new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
- memset (new, 0, sizeof (struct bgp_info));
-
- return new;
+ return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
}
/* Free bgp route information. */
@@ -3121,10 +3116,7 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt,
static struct bgp_static *
bgp_static_new ()
{
- struct bgp_static *new;
- new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
- memset (new, 0, sizeof (struct bgp_static));
- return new;
+ return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
}
static void
@@ -4509,10 +4501,7 @@ struct bgp_aggregate
static struct bgp_aggregate *
bgp_aggregate_new ()
{
- struct bgp_aggregate *new;
- new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
- memset (new, 0, sizeof (struct bgp_aggregate));
- return new;
+ return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
}
static void
@@ -10859,10 +10848,7 @@ struct bgp_distance
static struct bgp_distance *
bgp_distance_new ()
{
- struct bgp_distance *new;
- new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
- memset (new, 0, sizeof (struct bgp_distance));
- return new;
+ return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
}
static void
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index d86937ba..4fff0268 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -956,8 +956,7 @@ route_set_ip_nexthop_compile (const char *arg)
}
}
- rins = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_ip_nexthop_set));
- memset (rins, 0, sizeof (struct rmap_ip_nexthop_set));
+ rins = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_ip_nexthop_set));
rins->address = address;
rins->peer_address = peer_address;
@@ -1426,9 +1425,7 @@ route_set_community_compile (const char *arg)
return NULL;
}
- rcs = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set));
- memset (rcs, 0, sizeof (struct rmap_com_set));
-
+ rcs = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set));
rcs->com = com;
rcs->additive = additive;
rcs->none = none;
@@ -1790,9 +1787,7 @@ route_set_aggregator_as_compile (const char *arg)
char as[10];
char address[20];
- aggregator = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct aggregator));
- memset (aggregator, 0, sizeof (struct aggregator));
-
+ aggregator = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct aggregator));
sscanf (arg, "%s %s", as, address);
aggregator->as = strtoul (as, NULL, 10);
diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c
index c2120252..eb7c9f27 100644
--- a/bgpd/bgp_table.c
+++ b/bgpd/bgp_table.c
@@ -36,8 +36,7 @@ bgp_table_init (afi_t afi, safi_t safi)
{
struct bgp_table *rt;
- rt = XMALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table));
- memset (rt, 0, sizeof (struct bgp_table));
+ rt = XCALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table));
rt->type = BGP_TABLE_MAIN;
rt->afi = afi;
@@ -56,11 +55,7 @@ bgp_table_finish (struct bgp_table **rt)
static struct bgp_node *
bgp_node_create ()
{
- struct bgp_node *rn;
-
- rn = (struct bgp_node *) XMALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node));
- memset (rn, 0, sizeof (struct bgp_node));
- return rn;
+ return XCALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node));
}
/* Allocate new route node with prefix set. */