summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--lib/distribute.c7
-rw-r--r--lib/hash.c3
-rw-r--r--lib/if.c4
-rw-r--r--lib/keychain.c10
-rw-r--r--lib/linklist.c12
-rw-r--r--lib/sockunion.c3
-rw-r--r--lib/zclient.c3
-rw-r--r--ospf6d/ospf6_asbr.c3
-rw-r--r--ospf6d/ospf6_interface.c6
-rw-r--r--ospf6d/ospf6_lsa.c6
-rw-r--r--ospf6d/ospf6_top.c3
-rw-r--r--ospfclient/ospf_apiclient.c3
-rw-r--r--ospfd/ospf_api.c10
-rw-r--r--ospfd/ospf_apiserver.c3
-rw-r--r--ospfd/ospf_asbr.c3
-rw-r--r--ospfd/ospf_interface.c17
-rw-r--r--ospfd/ospf_lsa.c15
-rw-r--r--ospfd/ospf_neighbor.c3
-rw-r--r--ospfd/ospf_snmp.c6
-rw-r--r--ospfd/ospf_te.c6
-rw-r--r--ospfd/ospf_zebra.c5
-rw-r--r--ospfd/ospfd.c3
-rw-r--r--ripd/rip_interface.c3
-rw-r--r--ripd/rip_offset.c6
-rw-r--r--ripd/rip_peer.c6
-rw-r--r--ripd/ripd.c16
-rw-r--r--ripngd/ripng_peer.c6
-rw-r--r--ripngd/ripngd.c3
-rw-r--r--vtysh/vtysh_user.c5
-rw-r--r--zebra/interface.c3
-rw-r--r--zebra/irdp_interface.c5
-rw-r--r--zebra/rtadv.c12
-rw-r--r--zebra/zebra_rib.c30
41 files changed, 79 insertions, 248 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. */
diff --git a/lib/distribute.c b/lib/distribute.c
index 906e3f6d..242a225c 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -38,12 +38,7 @@ void (*distribute_delete_hook) (struct distribute *);
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 3884051f..672327ec 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -32,9 +32,8 @@ hash_create_size (unsigned int size, unsigned int (*hash_key) (void *),
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 db590f56..de3f641d 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -620,9 +620,7 @@ DEFUN (show_address,
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 10928b11..af0a1d74 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -31,10 +31,7 @@ struct list *keychain_list;
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 @@ keychain_free (struct keychain *keychain)
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 a16e9e18..485a80be 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 @@ list_free (struct list *l)
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 3750295c..75419b11 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -180,8 +180,7 @@ sockunion_str2su (const char *str)
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 10e6b5fd..4a716a66 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -49,8 +49,7 @@ struct zclient *
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 37b912b4..685b147c 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -504,8 +504,7 @@ ospf6_asbr_redistribute_add (int type, int ifindex, struct prefix *prefix,
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 8d9a7f01..42152084 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -96,11 +96,9 @@ ospf6_interface_create (struct interface *ifp)
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 87df7418..e8290b63 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -468,8 +468,7 @@ ospf6_lsa_create (struct ospf6_lsa_header *header)
/* 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 @@ ospf6_lsa_create_headeronly (struct ospf6_lsa_header *header)
/* 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 f59b6f95..d45d1321 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -114,8 +114,7 @@ ospf6_create (void)
{
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 64b83123..ed7ca947 100644
--- a/ospfclient/ospf_apiclient.c
+++ b/ospfclient/ospf_apiclient.c
@@ -259,8 +259,7 @@ ospf_apiclient_connect (char *host, int syncport)
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 9c9997ba..77383191 100644
--- a/ospfd/ospf_api.c
+++ b/ospfd/ospf_api.c
@@ -99,8 +99,7 @@ msg_new (u_char msgtype, void *msgbody, u_int32_t seqnum, u_int16_t msglen)
{
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 @@ msg_get_seq (struct msg *msg)
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 dac4c93f..15fd2e5f 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -937,8 +937,7 @@ ospf_apiserver_register_opaque_type (struct ospf_apiserver *apiserv,
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 a4826237..6f1b0b06 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -104,8 +104,7 @@ ospf_external_info_new (u_char type)
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 63681429..951c19a8 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -508,13 +508,11 @@ ospf_new_if_params (void)
{
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 @@ ospf_if_new_hook (struct interface *ifp)
{
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 @@ ospf_vl_data_new (struct ospf_area *area, struct in_addr vl_peer)
{
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 @@ ospf_vls_in_area (struct ospf_area *area)
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 f453353d..3c9c73a3 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -304,12 +304,7 @@ ospf_lsa_discard (struct ospf_lsa *lsa)
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 @@ ospf_schedule_lsa_flood_area (struct ospf_area *area, struct ospf_lsa *lsa)
{
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 @@ ospf_schedule_lsa_flush_area (struct ospf_area *area, struct ospf_lsa *lsa)
{
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 843e93f6..967ca15d 100644
--- a/ospfd/ospf_neighbor.c
+++ b/ospfd/ospf_neighbor.c
@@ -69,8 +69,7 @@ ospf_nbr_new (struct ospf_interface *oi)
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 c47d432e..5a0aea1a 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -1405,11 +1405,7 @@ struct ospf_snmp_if
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 a3ebe62e..c5ec0ad8 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -561,13 +561,13 @@ ospf_mpls_te_new_if (struct interface *ifp)
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 e27f1394..150ffac3 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -1113,10 +1113,7 @@ ospf_prefix_list_update (struct prefix_list *plist)
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 c951a29a..f2784887 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -1390,9 +1390,8 @@ ospf_nbr_nbma_new (void)
{
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 7c5577b4..54d357ce 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -118,8 +118,7 @@ rip_interface_new (void)
{
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 e7d71f6c..0155f90e 100644
--- a/ripd/rip_offset.c
+++ b/ripd/rip_offset.c
@@ -63,11 +63,7 @@ strcmp_safe (const char *s1, const char *s2)
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 e0617890..fd912eba 100644
--- a/ripd/rip_peer.c
+++ b/ripd/rip_peer.c
@@ -36,11 +36,7 @@ struct list *peer_list;
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 2525679c..cb2603d0 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -110,13 +110,9 @@ rip_route_rte (struct rip_info *rinfo)
}
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 @@ rip_redistribute_withdraw (int type)
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 @@ struct rip_distance
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 1e58bb87..c04456b8 100644
--- a/ripngd/ripng_peer.c
+++ b/ripngd/ripng_peer.c
@@ -42,11 +42,7 @@ struct list *peer_list;
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 5e9bfc54..7b00e037 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -1820,8 +1820,7 @@ ripng_create (void)
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 e3015056..58676c10 100644
--- a/vtysh/vtysh_user.c
+++ b/vtysh/vtysh_user.c
@@ -101,10 +101,7 @@ struct list *userlist;
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 184b42a0..9cbbf937 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -48,8 +48,7 @@ if_zebra_new_hook (struct interface *ifp)
{
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 dd773402..b3a838b3 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -175,10 +175,7 @@ if_set_defaults(struct interface *ifp)
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 4bdb83d5..e1fd0dc8 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -84,10 +84,7 @@ struct rtadv *rtadv = NULL;
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 @@ rtadv_make_socket (void)
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 90db932b..cc63dba0 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -209,8 +209,7 @@ nexthop_ifindex_add (struct rib *rib, unsigned int ifindex)
{
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 @@ nexthop_ifname_add (struct rib *rib, char *ifname)
{
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 @@ nexthop_ipv4_add (struct rib *rib, struct in_addr *ipv4, struct in_addr *src)
{
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 @@ nexthop_ipv4_ifindex_add (struct rib *rib, struct in_addr *ipv4,
{
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 @@ nexthop_ipv6_add (struct rib *rib, struct in6_addr *ipv6)
{
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 @@ nexthop_ipv6_ifname_add (struct rib *rib, struct in6_addr *ipv6,
{
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 @@ nexthop_ipv6_ifindex_add (struct rib *rib, struct in6_addr *ipv6,
{
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 @@ nexthop_blackhole_add (struct rib *rib)
{
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_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
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 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate,
}
/* 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;