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/methods/generic_poly1305/generic_poly1305.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/methods/generic_poly1305') diff --git a/src/methods/generic_poly1305/generic_poly1305.c b/src/methods/generic_poly1305/generic_poly1305.c index 142b50e..f804ba3 100644 --- a/src/methods/generic_poly1305/generic_poly1305.c +++ b/src/methods/generic_poly1305/generic_poly1305.c @@ -84,7 +84,7 @@ static bool method_create_by_name(const char *name, fastd_method_t **method) { if (m.cipher_info->iv_length <= COMMON_NONCEBYTES) return false; - *method = malloc(sizeof(fastd_method_t)); + *method = fastd_new(fastd_method_t); **method = m; return true; @@ -102,7 +102,7 @@ static size_t method_key_length(const fastd_method_t *method) { /** Initializes a session */ static fastd_method_session_state_t* method_session_init(const fastd_method_t *method, const uint8_t *secret, bool initiator) { - fastd_method_session_state_t *session = malloc(sizeof(fastd_method_session_state_t)); + fastd_method_session_state_t *session = fastd_new(fastd_method_session_state_t); fastd_method_common_init(&session->common, initiator); session->method = method; -- cgit v1.2.3