[cleanup] Convert XMALLOC/memset to XCALLOC
Simple conversion of XMALLOC/memset to XCALLOC
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index d0d621c..5881abe 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -322,11 +322,7 @@
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 f38db41..5839d3f 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -153,8 +153,7 @@
{
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 @@
/* 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 f75fc55..a8d8742 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -51,11 +51,7 @@
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 @@
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 ab7f070..eb4ff8e 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -99,11 +99,7 @@
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 @@
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 22e48db..b2ee7f3 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -98,11 +98,7 @@
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 @@
}
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 @@
}
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 @@
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 @@
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 6b7828c..5177dc0 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -129,12 +129,7 @@
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 @@
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 @@
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 @@
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 d86937b..4fff026 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -956,8 +956,7 @@
}
}
- 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 @@
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 @@
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 c212025..eb7c9f2 100644
--- a/bgpd/bgp_table.c
+++ b/bgpd/bgp_table.c
@@ -36,8 +36,7 @@
{
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 @@
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. */
diff --git a/lib/distribute.c b/lib/distribute.c
index 906e3f6..242a225 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -38,12 +38,7 @@
static struct distribute *
distribute_new (void)
{
- struct distribute *new;
-
- new = XMALLOC (MTYPE_DISTRIBUTE, sizeof (struct distribute));
- memset (new, 0, sizeof (struct distribute));
-
- return new;
+ return XCALLOC (MTYPE_DISTRIBUTE, sizeof (struct distribute));
}
/* Free distribute object. */
diff --git a/lib/hash.c b/lib/hash.c
index 3884051..672327e 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -32,9 +32,8 @@
struct hash *hash;
hash = XMALLOC (MTYPE_HASH, sizeof (struct hash));
- hash->index = XMALLOC (MTYPE_HASH_INDEX,
+ hash->index = XCALLOC (MTYPE_HASH_INDEX,
sizeof (struct hash_backet *) * size);
- memset (hash->index, 0, sizeof (struct hash_backet *) * size);
hash->size = size;
hash->hash_key = hash_key;
hash->hash_cmp = hash_cmp;
diff --git a/lib/if.c b/lib/if.c
index db590f5..de3f641 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -620,9 +620,7 @@
struct connected *
connected_new (void)
{
- struct connected *new = XMALLOC (MTYPE_CONNECTED, sizeof (struct connected));
- memset (new, 0, sizeof (struct connected));
- return new;
+ return XCALLOC (MTYPE_CONNECTED, sizeof (struct connected));
}
/* Free connected structure. */
diff --git a/lib/keychain.c b/lib/keychain.c
index 10928b1..af0a1d7 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -31,10 +31,7 @@
static struct keychain *
keychain_new (void)
{
- struct keychain *new;
- new = XMALLOC (MTYPE_KEYCHAIN, sizeof (struct keychain));
- memset (new, 0, sizeof (struct keychain));
- return new;
+ return XCALLOC (MTYPE_KEYCHAIN, sizeof (struct keychain));
}
static void
@@ -46,10 +43,7 @@
static struct key *
key_new (void)
{
- struct key *new;
- new = XMALLOC (MTYPE_KEY, sizeof (struct key));
- memset (new, 0, sizeof (struct key));
- return new;
+ return XCALLOC (MTYPE_KEY, sizeof (struct key));
}
static void
diff --git a/lib/linklist.c b/lib/linklist.c
index a16e9e1..485a80b 100644
--- a/lib/linklist.c
+++ b/lib/linklist.c
@@ -28,11 +28,7 @@
struct list *
list_new (void)
{
- struct list *new;
-
- new = XMALLOC (MTYPE_LINK_LIST, sizeof (struct list));
- memset (new, 0, sizeof (struct list));
- return new;
+ return XCALLOC (MTYPE_LINK_LIST, sizeof (struct list));
}
/* Free list. */
@@ -46,11 +42,7 @@
static struct listnode *
listnode_new (void)
{
- struct listnode *node;
-
- node = XMALLOC (MTYPE_LINK_NODE, sizeof (struct listnode));
- memset (node, 0, sizeof (struct listnode));
- return node;
+ return XCALLOC (MTYPE_LINK_NODE, sizeof (struct listnode));
}
/* Free listnode. */
diff --git a/lib/sockunion.c b/lib/sockunion.c
index 3750295..75419b1 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -180,8 +180,7 @@
int ret;
union sockunion *su;
- su = XMALLOC (MTYPE_SOCKUNION, sizeof (union sockunion));
- memset (su, 0, sizeof (union sockunion));
+ su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion));
ret = inet_pton (AF_INET, str, &su->sin.sin_addr);
if (ret > 0) /* Valid IPv4 address format. */
diff --git a/lib/zclient.c b/lib/zclient.c
index 10e6b5f..4a716a6 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -49,8 +49,7 @@
zclient_new ()
{
struct zclient *zclient;
- zclient = XMALLOC (MTYPE_ZCLIENT, sizeof (struct zclient));
- memset (zclient, 0, sizeof (struct zclient));
+ zclient = XCALLOC (MTYPE_ZCLIENT, sizeof (struct zclient));
zclient->ibuf = stream_new (ZEBRA_MAX_PACKET_SIZ);
zclient->obuf = stream_new (ZEBRA_MAX_PACKET_SIZ);
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index 37b912b..685b147 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -504,8 +504,7 @@
memcpy (&route->prefix, prefix, sizeof (struct prefix));
info = (struct ospf6_external_info *)
- XMALLOC (MTYPE_OSPF6_EXTERNAL_INFO, sizeof (struct ospf6_external_info));
- memset (info, 0, sizeof (struct ospf6_external_info));
+ XCALLOC (MTYPE_OSPF6_EXTERNAL_INFO, sizeof (struct ospf6_external_info));
route->route_option = info;
info->id = ospf6->external_id++;
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 8d9a7f0..4215208 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -96,11 +96,9 @@
unsigned int iobuflen;
oi = (struct ospf6_interface *)
- XMALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
+ XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface));
- if (oi)
- memset (oi, 0, sizeof (struct ospf6_interface));
- else
+ if (!oi)
{
zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex);
return (struct ospf6_interface *) NULL;
diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c
index 87df741..e8290b6 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -468,8 +468,7 @@
/* LSA information structure */
/* allocate memory */
lsa = (struct ospf6_lsa *)
- XMALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa));
- memset (lsa, 0, sizeof (struct ospf6_lsa));
+ XCALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa));
lsa->header = (struct ospf6_lsa_header *) new_header;
@@ -498,8 +497,7 @@
/* LSA information structure */
/* allocate memory */
lsa = (struct ospf6_lsa *)
- XMALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa));
- memset (lsa, 0, sizeof (struct ospf6_lsa));
+ XCALLOC (MTYPE_OSPF6_LSA, sizeof (struct ospf6_lsa));
lsa->header = (struct ospf6_lsa_header *) new_header;
SET_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY);
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index f59b6f9..d45d132 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -114,8 +114,7 @@
{
struct ospf6 *o;
- o = XMALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
- memset (o, 0, sizeof (struct ospf6));
+ o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
/* initialize */
gettimeofday (&o->starttime, (struct timezone *) NULL);
diff --git a/ospfclient/ospf_apiclient.c b/ospfclient/ospf_apiclient.c
index 64b8312..ed7ca94 100644
--- a/ospfclient/ospf_apiclient.c
+++ b/ospfclient/ospf_apiclient.c
@@ -259,8 +259,7 @@
close (async_server_sock);
/* Create new client-side instance */
- new = XMALLOC (MTYPE_OSPF_APICLIENT, sizeof (struct ospf_apiclient));
- memset (new, 0, sizeof (struct ospf_apiclient));
+ new = XCALLOC (MTYPE_OSPF_APICLIENT, sizeof (struct ospf_apiclient));
/* Initialize socket descriptors for sync and async channels */
new->fd_sync = fd1;
diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c
index 9c9997b..7738319 100644
--- a/ospfd/ospf_api.c
+++ b/ospfd/ospf_api.c
@@ -99,8 +99,7 @@
{
struct msg *new;
- new = XMALLOC (MTYPE_OSPF_API_MSG, sizeof (struct msg));
- memset (new, 0, sizeof (struct msg));
+ new = XCALLOC (MTYPE_OSPF_API_MSG, sizeof (struct msg));
new->hdr.version = OSPF_API_VERSION;
new->hdr.msgtype = msgtype;
@@ -271,12 +270,7 @@
struct msg_fifo *
msg_fifo_new ()
{
- struct msg_fifo *new;
-
- new = XMALLOC (MTYPE_OSPF_API_FIFO, sizeof (struct msg_fifo));
- memset (new, 0, sizeof (struct msg_fifo));
-
- return new;
+ return XCALLOC (MTYPE_OSPF_API_FIFO, sizeof (struct msg_fifo));
}
/* Add new message to fifo. */
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index dac4c93..15fd2e5 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -937,8 +937,7 @@
type. */
regtype =
- XMALLOC (MTYPE_OSPF_APISERVER, sizeof (struct registered_opaque_type));
- memset (regtype, 0, sizeof (struct registered_opaque_type));
+ XCALLOC (MTYPE_OSPF_APISERVER, sizeof (struct registered_opaque_type));
regtype->lsa_type = lsa_type;
regtype->opaque_type = opaque_type;
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index a482623..6f1b0b0 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -104,8 +104,7 @@
struct external_info *new;
new = (struct external_info *)
- XMALLOC (MTYPE_OSPF_EXTERNAL_INFO, sizeof (struct external_info));
- memset (new, 0, sizeof (struct external_info));
+ XCALLOC (MTYPE_OSPF_EXTERNAL_INFO, sizeof (struct external_info));
new->type = type;
ospf_reset_route_map_set_values (&new->route_map_set);
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 6368142..951c19a 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -508,13 +508,11 @@
{
struct ospf_if_params *oip;
- oip = XMALLOC (MTYPE_OSPF_IF_PARAMS, sizeof (struct ospf_if_params));
+ oip = XCALLOC (MTYPE_OSPF_IF_PARAMS, sizeof (struct ospf_if_params));
if (!oip)
return NULL;
- memset (oip, 0, sizeof (struct ospf_if_params));
-
UNSET_IF_PARAM (oip, output_cost_cmd);
UNSET_IF_PARAM (oip, transmit_delay);
UNSET_IF_PARAM (oip, retransmit_interval);
@@ -638,8 +636,7 @@
{
int rc = 0;
- ifp->info = XMALLOC (MTYPE_OSPF_IF_INFO, sizeof (struct ospf_if_info));
- memset (ifp->info, 0, sizeof (struct ospf_if_info));
+ ifp->info = XCALLOC (MTYPE_OSPF_IF_INFO, sizeof (struct ospf_if_info));
IF_OIFS (ifp) = route_table_init ();
IF_OIFS_PARAMS (ifp) = route_table_init ();
@@ -814,8 +811,7 @@
{
struct ospf_vl_data *vl_data;
- vl_data = XMALLOC (MTYPE_OSPF_VL_DATA, sizeof (struct ospf_vl_data));
- memset (vl_data, 0, sizeof (struct ospf_vl_data));
+ vl_data = XCALLOC (MTYPE_OSPF_VL_DATA, sizeof (struct ospf_vl_data));
vl_data->vl_peer.s_addr = vl_peer.s_addr;
vl_data->vl_area_id = area->area_id;
@@ -1180,12 +1176,7 @@
struct crypt_key *
ospf_crypt_key_new ()
{
- struct crypt_key *ck;
-
- ck = XMALLOC (MTYPE_OSPF_CRYPT_KEY, sizeof (struct crypt_key));
- memset (ck, 0, sizeof (struct crypt_key));
-
- return ck;
+ return XCALLOC (MTYPE_OSPF_CRYPT_KEY, sizeof (struct crypt_key));
}
void
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index f453353..3c9c73a 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -304,12 +304,7 @@
struct lsa_header *
ospf_lsa_data_new (size_t size)
{
- struct lsa_header *new;
-
- new = (struct lsa_header *) XMALLOC (MTYPE_OSPF_LSA_DATA, size);
- memset (new, 0, size);
-
- return new;
+ return XCALLOC (MTYPE_OSPF_LSA_DATA, size);
}
/* Duplicate LSA data. */
@@ -3635,9 +3630,7 @@
{
struct lsa_action *data;
- data = XMALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
- memset (data, 0, sizeof (struct lsa_action));
-
+ data = XCALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
data->action = LSA_ACTION_FLOOD_AREA;
data->area = area;
data->lsa = ospf_lsa_lock (lsa); /* Message / Flood area */
@@ -3650,9 +3643,7 @@
{
struct lsa_action *data;
- data = XMALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
- memset (data, 0, sizeof (struct lsa_action));
-
+ data = XCALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
data->action = LSA_ACTION_FLUSH_AREA;
data->area = area;
data->lsa = ospf_lsa_lock (lsa); /* Message / Flush area */
diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c
index 843e93f..967ca15 100644
--- a/ospfd/ospf_neighbor.c
+++ b/ospfd/ospf_neighbor.c
@@ -69,8 +69,7 @@
struct ospf_neighbor *nbr;
/* Allcate new neighbor. */
- nbr = XMALLOC (MTYPE_OSPF_NEIGHBOR, sizeof (struct ospf_neighbor));
- memset (nbr, 0, sizeof (struct ospf_neighbor));
+ nbr = XCALLOC (MTYPE_OSPF_NEIGHBOR, sizeof (struct ospf_neighbor));
/* Relate neighbor to the interface. */
nbr->oi = oi;
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index c47d432..5a0aea1 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -1405,11 +1405,7 @@
static struct ospf_snmp_if *
ospf_snmp_if_new ()
{
- struct ospf_snmp_if *osif;
-
- osif = XMALLOC (0, sizeof (struct ospf_snmp_if));
- memset (osif, 0, sizeof (struct ospf_snmp_if));
- return osif;
+ return XCALLOC (0, sizeof (struct ospf_snmp_if));
}
static void
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index a3ebe62..c5ec0ad 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -561,13 +561,13 @@
goto out;
}
- if ((new = XMALLOC (MTYPE_OSPF_MPLS_TE_LINKPARAMS,
- sizeof (struct mpls_te_link))) == NULL)
+ new = XCALLOC (MTYPE_OSPF_MPLS_TE_LINKPARAMS,
+ sizeof (struct mpls_te_link));
+ if (new == NULL)
{
zlog_warn ("ospf_mpls_te_new_if: XMALLOC: %s", safe_strerror (errno));
goto out;
}
- memset (new, 0, sizeof (struct mpls_te_link));
new->area = NULL;
new->flags = 0;
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index e27f139..150ffac 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -1113,10 +1113,7 @@
static struct ospf_distance *
ospf_distance_new (void)
{
- struct ospf_distance *new;
- new = XMALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance));
- memset (new, 0, sizeof (struct ospf_distance));
- return new;
+ return XCALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance));
}
static void
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index c951a29..f278488 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -1390,9 +1390,8 @@
{
struct ospf_nbr_nbma *nbr_nbma;
- nbr_nbma = XMALLOC (MTYPE_OSPF_NEIGHBOR_STATIC,
+ nbr_nbma = XCALLOC (MTYPE_OSPF_NEIGHBOR_STATIC,
sizeof (struct ospf_nbr_nbma));
- memset (nbr_nbma, 0, sizeof (struct ospf_nbr_nbma));
nbr_nbma->priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
nbr_nbma->v_poll = OSPF_POLL_INTERVAL_DEFAULT;
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 7c5577b..54d357c 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -118,8 +118,7 @@
{
struct rip_interface *ri;
- ri = XMALLOC (MTYPE_RIP_INTERFACE, sizeof (struct rip_interface));
- memset (ri, 0, sizeof (struct rip_interface));
+ ri = XCALLOC (MTYPE_RIP_INTERFACE, sizeof (struct rip_interface));
/* Default authentication type is simple password for Cisco
compatibility. */
diff --git a/ripd/rip_offset.c b/ripd/rip_offset.c
index e7d71f6..0155f90 100644
--- a/ripd/rip_offset.c
+++ b/ripd/rip_offset.c
@@ -63,11 +63,7 @@
static struct rip_offset_list *
rip_offset_list_new (void)
{
- struct rip_offset_list *new;
-
- new = XMALLOC (MTYPE_RIP_OFFSET_LIST, sizeof (struct rip_offset_list));
- memset (new, 0, sizeof (struct rip_offset_list));
- return new;
+ return XCALLOC (MTYPE_RIP_OFFSET_LIST, sizeof (struct rip_offset_list));
}
static void
diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c
index e061789..fd912eb 100644
--- a/ripd/rip_peer.c
+++ b/ripd/rip_peer.c
@@ -36,11 +36,7 @@
static struct rip_peer *
rip_peer_new (void)
{
- struct rip_peer *new;
-
- new = XMALLOC (MTYPE_RIP_PEER, sizeof (struct rip_peer));
- memset (new, 0, sizeof (struct rip_peer));
- return new;
+ return XCALLOC (MTYPE_RIP_PEER, sizeof (struct rip_peer));
}
static void
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 2525679..cb2603d 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -110,13 +110,9 @@
}
static struct rip_info *
-rip_info_new ()
+rip_info_new (void)
{
- struct rip_info *new;
-
- new = XMALLOC (MTYPE_RIP_INFO, sizeof (struct rip_info));
- memset (new, 0, sizeof (struct rip_info));
- return new;
+ return XCALLOC (MTYPE_RIP_INFO, sizeof (struct rip_info));
}
void
@@ -2697,8 +2693,7 @@
static int
rip_create (void)
{
- rip = XMALLOC (MTYPE_RIP, sizeof (struct rip));
- memset (rip, 0, sizeof (struct rip));
+ rip = XCALLOC (MTYPE_RIP, sizeof (struct rip));
/* Set initial value. */
rip->version_send = RI_RIP_VERSION_2;
@@ -3117,10 +3112,7 @@
static struct rip_distance *
rip_distance_new (void)
{
- struct rip_distance *new;
- new = XMALLOC (MTYPE_RIP_DISTANCE, sizeof (struct rip_distance));
- memset (new, 0, sizeof (struct rip_distance));
- return new;
+ return XCALLOC (MTYPE_RIP_DISTANCE, sizeof (struct rip_distance));
}
static void
diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c
index 1e58bb8..c04456b 100644
--- a/ripngd/ripng_peer.c
+++ b/ripngd/ripng_peer.c
@@ -42,11 +42,7 @@
static struct ripng_peer *
ripng_peer_new (void)
{
- struct ripng_peer *new;
-
- new = XMALLOC (MTYPE_RIPNG_PEER, sizeof (struct ripng_peer));
- memset (new, 0, sizeof (struct ripng_peer));
- return new;
+ return XCALLOC (MTYPE_RIPNG_PEER, sizeof (struct ripng_peer));
}
static void
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 5e9bfc5..7b00e03 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -1820,8 +1820,7 @@
assert (ripng == NULL);
/* Allocaste RIPng instance. */
- ripng = XMALLOC (MTYPE_RIPNG, sizeof (struct ripng));
- memset (ripng, 0, sizeof (struct ripng));
+ ripng = XCALLOC (MTYPE_RIPNG, sizeof (struct ripng));
/* Default version and timer values. */
ripng->version = RIPNG_V1;
diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c
index e301505..58676c1 100644
--- a/vtysh/vtysh_user.c
+++ b/vtysh/vtysh_user.c
@@ -101,10 +101,7 @@
struct vtysh_user *
user_new ()
{
- struct vtysh_user *user;
- user = XMALLOC (0, sizeof (struct vtysh_user));
- memset (user, 0, sizeof (struct vtysh_user));
- return user;
+ return XCALLOC (0, sizeof (struct vtysh_user));
}
void
diff --git a/zebra/interface.c b/zebra/interface.c
index 184b42a..9cbbf93 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -48,8 +48,7 @@
{
struct zebra_if *zebra_if;
- zebra_if = XMALLOC (MTYPE_TMP, sizeof (struct zebra_if));
- memset (zebra_if, 0, sizeof (struct zebra_if));
+ zebra_if = XCALLOC (MTYPE_TMP, sizeof (struct zebra_if));
zebra_if->multicast = IF_ZEBRA_MULTICAST_UNSPEC;
zebra_if->shutdown = IF_ZEBRA_SHUTDOWN_UNSPEC;
diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c
index dd77340..b3a838b 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -175,10 +175,7 @@
struct Adv *Adv_new (void)
{
- struct Adv *new;
- new = XMALLOC (MTYPE_TMP, sizeof (struct Adv));
- memset (new, 0, sizeof (struct Adv));
- return new;
+ return XCALLOC (MTYPE_TMP, sizeof (struct Adv));
}
static void
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 4bdb83d..e1fd0dc 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -84,10 +84,7 @@
static struct rtadv *
rtadv_new (void)
{
- struct rtadv *new;
- new = XMALLOC (MTYPE_TMP, sizeof (struct rtadv));
- memset (new, 0, sizeof (struct rtadv));
- return new;
+ return XCALLOC (MTYPE_TMP, sizeof (struct rtadv));
}
static void
@@ -529,12 +526,7 @@
static struct rtadv_prefix *
rtadv_prefix_new ()
{
- struct rtadv_prefix *new;
-
- new = XMALLOC (MTYPE_RTADV_PREFIX, sizeof (struct rtadv_prefix));
- memset (new, 0, sizeof (struct rtadv_prefix));
-
- return new;
+ return XCALLOC (MTYPE_RTADV_PREFIX, sizeof (struct rtadv_prefix));
}
static void
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 90db932..cc63dba 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -209,8 +209,7 @@
{
struct nexthop *nexthop;
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = NEXTHOP_TYPE_IFINDEX;
nexthop->ifindex = ifindex;
@@ -224,8 +223,7 @@
{
struct nexthop *nexthop;
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = NEXTHOP_TYPE_IFNAME;
nexthop->ifname = XSTRDUP (0, ifname);
@@ -239,8 +237,7 @@
{
struct nexthop *nexthop;
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = NEXTHOP_TYPE_IPV4;
nexthop->gate.ipv4 = *ipv4;
if (src)
@@ -257,8 +254,7 @@
{
struct nexthop *nexthop;
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = NEXTHOP_TYPE_IPV4_IFINDEX;
nexthop->gate.ipv4 = *ipv4;
if (src)
@@ -276,8 +272,7 @@
{
struct nexthop *nexthop;
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = NEXTHOP_TYPE_IPV6;
nexthop->gate.ipv6 = *ipv6;
@@ -292,8 +287,7 @@
{
struct nexthop *nexthop;
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = NEXTHOP_TYPE_IPV6_IFNAME;
nexthop->gate.ipv6 = *ipv6;
nexthop->ifname = XSTRDUP (0, ifname);
@@ -309,8 +303,7 @@
{
struct nexthop *nexthop;
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
nexthop->gate.ipv6 = *ipv6;
nexthop->ifindex = ifindex;
@@ -326,8 +319,7 @@
{
struct nexthop *nexthop;
- nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
- memset (nexthop, 0, sizeof (struct nexthop));
+ nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
nexthop->type = NEXTHOP_TYPE_BLACKHOLE;
SET_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE);
@@ -2197,8 +2189,7 @@
static_delete_ipv4 (p, gate, ifname, update->distance, vrf_id);
/* Make new static route structure. */
- si = XMALLOC (MTYPE_STATIC_IPV4, sizeof (struct static_ipv4));
- memset (si, 0, sizeof (struct static_ipv4));
+ si = XCALLOC (MTYPE_STATIC_IPV4, sizeof (struct static_ipv4));
si->type = type;
si->distance = distance;
@@ -2741,8 +2732,7 @@
}
/* Make new static route structure. */
- si = XMALLOC (MTYPE_STATIC_IPV6, sizeof (struct static_ipv6));
- memset (si, 0, sizeof (struct static_ipv6));
+ si = XCALLOC (MTYPE_STATIC_IPV6, sizeof (struct static_ipv6));
si->type = type;
si->distance = distance;