From 546ac7936340312cf272969ff83317ae4d50d2b4 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 2 Aug 2014 00:53:47 +0200 Subject: 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). --- src/handshake.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/handshake.c') diff --git a/src/handshake.c b/src/handshake.c index e8b2197..23c9f4e 100644 --- a/src/handshake.c +++ b/src/handshake.c @@ -72,7 +72,7 @@ static uint8_t* create_method_list(size_t *len) { for (i = 0; conf.methods[i].name; i++) *len += strlen(conf.methods[i].name) + 1; - uint8_t *ret = malloc(*len); + uint8_t *ret = fastd_alloc(*len); (*len)--; char *ptr = (char*)ret; @@ -364,7 +364,7 @@ void fastd_handshake_handle(fastd_socket_t *sock, const fastd_peer_address_t *lo method = get_method(&handshake); if (handshake.records[RECORD_VERSION_NAME].data) - handshake.peer_version = peer_version = strndup((const char*)handshake.records[RECORD_VERSION_NAME].data, handshake.records[RECORD_VERSION_NAME].length); + handshake.peer_version = peer_version = fastd_strndup((const char*)handshake.records[RECORD_VERSION_NAME].data, handshake.records[RECORD_VERSION_NAME].length); } if (handshake.type > 1 && !method) { -- cgit v1.2.3