diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-08-18 14:13:29 -0700 |
---|---|---|
committer | Paul Jakma <paul@quagga.net> | 2009-06-12 17:07:49 +0100 |
commit | 393deb9bd663361e6b110d579a8b1d4c22667068 (patch) | |
tree | e93ebf2f57bf92ff7a9cd045764b3cdbb99a07e5 /lib | |
parent | 3453a7122c1d585ad789ed0f63deb90cc5e89fae (diff) |
[cleanup] Convert XMALLOC/memset to XCALLOC
Simple conversion of XMALLOC/memset to XCALLOC
Diffstat (limited to 'lib')
-rw-r--r-- | lib/distribute.c | 7 | ||||
-rw-r--r-- | lib/hash.c | 3 | ||||
-rw-r--r-- | lib/if.c | 4 | ||||
-rw-r--r-- | lib/keychain.c | 10 | ||||
-rw-r--r-- | lib/linklist.c | 12 | ||||
-rw-r--r-- | lib/sockunion.c | 3 | ||||
-rw-r--r-- | lib/zclient.c | 3 |
7 files changed, 9 insertions, 33 deletions
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. */ @@ -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; @@ -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); |