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:
}
config_t *new_config(void) {
}
config_t *new_config(void) {
- return xmalloc_and_zero(sizeof(config_t));
+ return xzalloc(sizeof(config_t));
}
void free_config(config_t *cfg) {
}
void free_config(config_t *cfg) {
}
connection_t *new_connection(void) {
}
connection_t *new_connection(void) {
- return xmalloc_and_zero(sizeof(connection_t));
+ return xzalloc(sizeof(connection_t));
}
void free_connection(connection_t *c) {
}
void free_connection(connection_t *c) {
/* Creation and deletion of connection elements */
edge_t *new_edge(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) {
}
void free_edge(edge_t *e) {
static struct addrinfo *malloc_ai(uint16_t port, uint32_t addr) {
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);
ai->ai_addr = (struct sockaddr *)(ai + 1);
ai->ai_addrlen = sizeof(struct sockaddr_in);
/* (De)allocation */
hash_t *hash_alloc(size_t n, size_t size) {
/* (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->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);
/* (De)constructors */
list_t *list_alloc(list_action_t delete) {
/* (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;
list->delete = delete;
return list;
}
list_node_t *list_alloc_node(void) {
}
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) {
}
void list_free_node(list_t *list, list_node_t *node) {
if(!found) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "Autoconnecting to %s", n->name);
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);
outgoing->name = xstrdup(n->name);
list_insert_tail(outgoing_list, outgoing);
setup_outgoing_connection(outgoing);
- 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);
outgoing->name = name;
list_insert_tail(outgoing_list, outgoing);
setup_outgoing_connection(outgoing);
}
node_t *new_node(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;
n->subnet_tree = new_subnet_tree();
n->edge_tree = new_edge_tree();
n->mtu = MTU;
} cipher_counter_t;
static cipher_t *cipher_open(const EVP_CIPHER *evp_cipher) {
} 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);
cipher->cipher = evp_cipher;
EVP_CIPHER_CTX_init(&cipher->ctx);
- cipher->counter = xmalloc_and_zero(sizeof *cipher->counter);
+ cipher->counter = xzalloc(sizeof *cipher->counter);
else
cipher->counter->n = 0;
else
cipher->counter->n = 0;
#include "../logger.h"
static digest_t *digest_open(const EVP_MD *evp_md, int maclength) {
#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);
digest->digest = evp_md;
int digestlen = EVP_MD_size(digest->digest);
splay_tree_t *splay_alloc_tree(splay_compare_t compare, splay_action_t delete) {
splay_tree_t *tree;
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;
tree->compare = compare;
tree->delete = delete;
}
splay_node_t *splay_alloc_node(void) {
}
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) {
}
void splay_free_node(splay_tree_t *tree, splay_node_t *node) {
/* Allocating and freeing space for subnets */
subnet_t *new_subnet(void) {
/* 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) {
}
void free_subnet(subnet_t *subnet) {
c = "tincd";
int nargc = 0;
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++)
nargv[nargc++] = c;
for(int i = 1; i < optind; i++)
found = ns;
break;
} else {
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;
found->name = xstrdup(name);
list_insert_before(&node_list, node, found);
changed = true;
- found = xmalloc_and_zero(sizeof *found);
+ found = xzalloc(sizeof *found);
found->name = xstrdup(name);
list_insert_tail(&node_list, found);
changed = true;
found->name = xstrdup(name);
list_insert_tail(&node_list, found);
changed = true;
/*
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.
/*
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
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
-static inline void *xmalloc_and_zero(size_t n) {
+static inline void *xzalloc(size_t n) {
void *p = calloc(1, n);
if(!p)
abort();
void *p = calloc(1, n);
if(!p)
abort();