From 2fabff13f11d9fd7ef8187546630f54f003ee4d9 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 4 May 2017 14:07:31 +0200 Subject: [PATCH] Refactor context_create(). --- src/oping.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/oping.c b/src/oping.c index 9ac87bf..adf769f 100644 --- a/src/oping.c +++ b/src/oping.c @@ -232,22 +232,17 @@ static void sigint_handler (int signal) /* {{{ */ opt_count = 0; } /* }}} void sigint_handler */ -static ping_context_t *context_create (void) /* {{{ */ +static ping_context_t *context_create () /* {{{ */ { - ping_context_t *ret; - - if ((ret = malloc (sizeof (ping_context_t))) == NULL) + ping_context_t *ctx = calloc (1, sizeof (*ctx)); + if (ctx == NULL) return (NULL); - memset (ret, '\0', sizeof (ping_context_t)); - - ret->latency_total = 0.0; - #if USE_NCURSES - ret->window = NULL; + ctx->window = NULL; #endif - return (ret); + return (ctx); } /* }}} ping_context_t *context_create */ static void context_destroy (ping_context_t *context) /* {{{ */ -- 2.30.2