Rename xmalloc_and_zero() to xzalloc().
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 1 May 2013 15:31:33 +0000 (17:31 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 1 May 2013 15:31:33 +0000 (17:31 +0200)
The former name is more or less only used by tinc, the latter is used by other
projects as well, and shorter as well.

16 files changed:
src/conf.c
src/connection.c
src/edge.c
src/fake-getaddrinfo.c
src/hash.c
src/list.c
src/net.c
src/net_socket.c
src/node.c
src/openssl/cipher.c
src/openssl/digest.c
src/splay_tree.c
src/subnet.c
src/tincctl.c
src/top.c
src/xalloc.h

index c4f8abb8303f649eff8f9f96eeb751f3f015d357..71e45092e0fa45e209302e1e8b5ed813b6050524 100644 (file)
@@ -71,7 +71,7 @@ void exit_configuration(splay_tree_t ** config_tree) {
 }
 
 config_t *new_config(void) {
-       return xmalloc_and_zero(sizeof(config_t));
+       return xzalloc(sizeof(config_t));
 }
 
 void free_config(config_t *cfg) {
index 9c459787eabbb5bc94a200a2dc01e3effbc1be58..496f6747fc05a738709f10e8c3783300c2685074 100644 (file)
@@ -48,7 +48,7 @@ void exit_connections(void) {
 }
 
 connection_t *new_connection(void) {
-       return xmalloc_and_zero(sizeof(connection_t));
+       return xzalloc(sizeof(connection_t));
 }
 
 void free_connection(connection_t *c) {
index fd033273296a41217e59551ea18145d7dc7b57b7..b34fdc29899dc3a187eb2dbc1198a8171666c2c2 100644 (file)
@@ -70,7 +70,7 @@ void exit_edges(void) {
 /* Creation and deletion of connection elements */
 
 edge_t *new_edge(void) {
-       return xmalloc_and_zero(sizeof(edge_t));
+       return xzalloc(sizeof(edge_t));
 }
 
 void free_edge(edge_t *e) {
index db50f739b6778a791bc8b4394127f16bca8ec14c..cb821b5f5785fa67ea22fb40192abbc40e704b59 100644 (file)
@@ -48,7 +48,7 @@ void freeaddrinfo(struct addrinfo *ai) {
 static struct addrinfo *malloc_ai(uint16_t port, uint32_t addr) {
        struct addrinfo *ai;
 
-       ai = xmalloc_and_zero(sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
+       ai = xzalloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
 
        ai->ai_addr = (struct sockaddr *)(ai + 1);
        ai->ai_addrlen = sizeof(struct sockaddr_in);
index 1d203c5cb31194982e6920cf5c063cee2ee43de0..36b510c28640db7647a69377d82c99de47062ffd 100644 (file)
@@ -52,11 +52,11 @@ static uint32_t modulo(uint32_t hash, size_t n) {
 /* (De)allocation */
 
 hash_t *hash_alloc(size_t n, size_t size) {
-       hash_t *hash = xmalloc_and_zero(sizeof *hash);
+       hash_t *hash = xzalloc(sizeof *hash);
        hash->n = n;
        hash->size = size;
-       hash->keys = xmalloc_and_zero(hash->n * hash->size);
-       hash->values = xmalloc_and_zero(hash->n * sizeof *hash->values);
+       hash->keys = xzalloc(hash->n * hash->size);
+       hash->values = xzalloc(hash->n * sizeof *hash->values);
        return hash;
 }
 
index 2dd414a0cdad467718b01be0f4dfd76cf9620d6f..e2eeabccfac7a4644ac89e8f387465da9a158a5b 100644 (file)
@@ -26,7 +26,7 @@
 /* (De)constructors */
 
 list_t *list_alloc(list_action_t delete) {
-       list_t *list = xmalloc_and_zero(sizeof(list_t));
+       list_t *list = xzalloc(sizeof(list_t));
        list->delete = delete;
 
        return list;
@@ -37,7 +37,7 @@ void list_free(list_t *list) {
 }
 
 list_node_t *list_alloc_node(void) {
-       return xmalloc_and_zero(sizeof(list_node_t));
+       return xzalloc(sizeof(list_node_t));
 }
 
 void list_free_node(list_t *list, list_node_t *node) {
index 1487e8182b7dd928b1a55bfd8d476fa584bc613e..d2eacf356c14efec800e16a0ab26633add271d2e 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -224,7 +224,7 @@ static void periodic_handler(void *data) {
 
                                if(!found) {
                                        logger(DEBUG_CONNECTIONS, LOG_INFO, "Autoconnecting to %s", n->name);
-                                       outgoing_t *outgoing = xmalloc_and_zero(sizeof *outgoing);
+                                       outgoing_t *outgoing = xzalloc(sizeof *outgoing);
                                        outgoing->name = xstrdup(n->name);
                                        list_insert_tail(outgoing_list, outgoing);
                                        setup_outgoing_connection(outgoing);
index 5332ed20326702c8de68bf6ce22b6df2ea560924..1b49aeeb4090865dd357cc235e1dffc24fe0de72 100644 (file)
@@ -674,7 +674,7 @@ void try_outgoing_connections(void) {
                }
 
                if(!found) {
-                       outgoing_t *outgoing = xmalloc_and_zero(sizeof *outgoing);
+                       outgoing_t *outgoing = xzalloc(sizeof *outgoing);
                        outgoing->name = name;
                        list_insert_tail(outgoing_list, outgoing);
                        setup_outgoing_connection(outgoing);
index 2f517446f717fd40b928e5df6d23b5a7e877355d..aab83ca7b020dc1e2a6bb38f2bb4d52dbe19bdcc 100644 (file)
@@ -50,9 +50,9 @@ void exit_nodes(void) {
 }
 
 node_t *new_node(void) {
-       node_t *n = xmalloc_and_zero(sizeof *n);
+       node_t *n = xzalloc(sizeof *n);
 
-       if(replaywin) n->late = xmalloc_and_zero(replaywin);
+       if(replaywin) n->late = xzalloc(replaywin);
        n->subnet_tree = new_subnet_tree();
        n->edge_tree = new_edge_tree();
        n->mtu = MTU;
index 32cb5ce2d138a491f0dfeae8fadfe4571da09ff8..7f73cb1bbc22e53f7b34025521783986e2b190d7 100644 (file)
@@ -40,7 +40,7 @@ typedef struct cipher_counter {
 } cipher_counter_t;
 
 static cipher_t *cipher_open(const EVP_CIPHER *evp_cipher) {
-       cipher_t *cipher = xmalloc_and_zero(sizeof *cipher);
+       cipher_t *cipher = xzalloc(sizeof *cipher);
        cipher->cipher = evp_cipher;
        EVP_CIPHER_CTX_init(&cipher->ctx);
 
@@ -135,7 +135,7 @@ bool cipher_set_counter_key(cipher_t *cipher, void *key) {
        }
 
        if(!cipher->counter)
-               cipher->counter = xmalloc_and_zero(sizeof *cipher->counter);
+               cipher->counter = xzalloc(sizeof *cipher->counter);
        else
                cipher->counter->n = 0;
 
index 9406701b8c3b5a7f224ad149ba5fcf4819db92b7..9699d37b5d94623ff00edbb5da3d2fcdb6a8a035 100644 (file)
@@ -29,7 +29,7 @@
 #include "../logger.h"
 
 static digest_t *digest_open(const EVP_MD *evp_md, int maclength) {
-       digest_t *digest = xmalloc_and_zero(sizeof *digest);
+       digest_t *digest = xzalloc(sizeof *digest);
        digest->digest = evp_md;
 
        int digestlen = EVP_MD_size(digest->digest);
index 54a46f28f6d56468fdc876e08a759cd0bd3fac6b..6b5b56f29892aa7be4ffec89bbf0a22f3586ef7a 100644 (file)
@@ -238,7 +238,7 @@ static void splay_bottom_up(splay_tree_t *tree, splay_node_t *node) {
 splay_tree_t *splay_alloc_tree(splay_compare_t compare, splay_action_t delete) {
        splay_tree_t *tree;
 
-       tree = xmalloc_and_zero(sizeof(splay_tree_t));
+       tree = xzalloc(sizeof(splay_tree_t));
        tree->compare = compare;
        tree->delete = delete;
 
@@ -250,7 +250,7 @@ void splay_free_tree(splay_tree_t *tree) {
 }
 
 splay_node_t *splay_alloc_node(void) {
-       return xmalloc_and_zero(sizeof(splay_node_t));
+       return xzalloc(sizeof(splay_node_t));
 }
 
 void splay_free_node(splay_tree_t *tree, splay_node_t *node) {
index 12ca03c73135d8e6e80596fba7793b02580ac7af..bf4300e4d9ad494a3eaf1054d63e139a324fbb50 100644 (file)
@@ -79,7 +79,7 @@ void free_subnet_tree(splay_tree_t *subnet_tree) {
 /* Allocating and freeing space for subnets */
 
 subnet_t *new_subnet(void) {
-       return xmalloc_and_zero(sizeof(subnet_t));
+       return xzalloc(sizeof(subnet_t));
 }
 
 void free_subnet(subnet_t *subnet) {
index a8930fe1d9d8d678f457f4afa85d7fa133616b2e..331299ae66e5df40b7a59613a629e82cdd6a6ee3 100644 (file)
@@ -792,7 +792,7 @@ static int cmd_start(int argc, char *argv[]) {
                c = "tincd";
 
        int nargc = 0;
-       char **nargv = xmalloc_and_zero((optind + argc) * sizeof *nargv);
+       char **nargv = xzalloc((optind + argc) * sizeof *nargv);
 
        nargv[nargc++] = c;
        for(int i = 1; i < optind; i++)
index 703391c5468476e36f13c659e82fe380eaec0ceb..b1ab40c454758bb6e9632d143aaa28297c758367 100644 (file)
--- a/src/top.c
+++ b/src/top.c
@@ -108,7 +108,7 @@ static void update(int fd) {
                                found = ns;
                                break;
                        } else {
-                               found = xmalloc_and_zero(sizeof *found);
+                               found = xzalloc(sizeof *found);
                                found->name = xstrdup(name);
                                list_insert_before(&node_list, node, found);
                                changed = true;
@@ -117,7 +117,7 @@ static void update(int fd) {
                }
 
                if(!found) {
-                       found = xmalloc_and_zero(sizeof *found);
+                       found = xzalloc(sizeof *found);
                        found->name = xstrdup(name);
                        list_insert_tail(&node_list, found);
                        changed = true;
index 42d0d9554adfe6ebf3ba562d7f6be9459a70c702..397f7b0e19bfce88f8034024547278bb721b32ad 100644 (file)
@@ -1,7 +1,7 @@
 /*
    xalloc.h -- malloc and related fuctions with out of memory checking
    Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
-   Copyright (C) 2011 Guus Sliepen <guus@tinc-vpn.org>
+   Copyright (C) 2011-2013 Guus Sliepen <guus@tinc-vpn.org>
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@ static inline void *xmalloc(size_t n) {
        return p;
 }
 
-static inline void *xmalloc_and_zero(size_t n) {
+static inline void *xzalloc(size_t n) {
        void *p = calloc(1, n);
        if(!p)
                abort();