From 393deb9bd663361e6b110d579a8b1d4c22667068 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 18 Aug 2008 14:13:29 -0700 Subject: [cleanup] Convert XMALLOC/memset to XCALLOC Simple conversion of XMALLOC/memset to XCALLOC --- lib/distribute.c | 7 +------ lib/hash.c | 3 +-- lib/if.c | 4 +--- lib/keychain.c | 10 ++-------- lib/linklist.c | 12 ++---------- lib/sockunion.c | 3 +-- lib/zclient.c | 3 +-- 7 files changed, 9 insertions(+), 33 deletions(-) (limited to 'lib') 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); -- cgit v1.2.1