From: Florian Forster Date: Thu, 4 May 2017 12:07:31 +0000 (+0200) Subject: Refactor context_create(). X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2fabff13f11d9fd7ef8187546630f54f003ee4d9;p=liboping.git Refactor context_create(). --- 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) /* {{{ */