summaryrefslogtreecommitdiffstats
path: root/src/socket.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-08-02 00:53:47 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-08-02 00:53:47 +0200
commit546ac7936340312cf272969ff83317ae4d50d2b4 (patch)
tree7ecadca11430c8624d9f80aae7c348fa4d65b969 /src/socket.c
parentb22364f4af3564f0dd9a5f4e150bb09747bd5c4e (diff)
downloadfastd-546ac7936340312cf272969ff83317ae4d50d2b4.tar
fastd-546ac7936340312cf272969ff83317ae4d50d2b4.zip
Introduce and use alloc helpers
These new helpers will terminate fastd on allocation failures and add some additional convenience (allow strdup with NULL; typesafe new(type) macros).
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/socket.c b/src/socket.c
index 5ab9fc1..c01eec8 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -185,7 +185,7 @@ static bool set_bound_address(fastd_socket_t *sock) {
return false;
}
- sock->bound_addr = calloc(1, sizeof(addr));
+ sock->bound_addr = fastd_new0(fastd_peer_address_t);
*sock->bound_addr = addr;
return true;
@@ -234,7 +234,7 @@ fastd_socket_t* fastd_socket_open(fastd_peer_t *peer, int af) {
if (fd < 0)
return NULL;
- fastd_socket_t *sock = malloc(sizeof(fastd_socket_t));
+ fastd_socket_t *sock = fastd_new(fastd_socket_t);
sock->fd = fd;
sock->addr = NULL;