From: Russell Bryant Date: Sat, 18 Mar 2006 19:16:36 +0000 (+0000) Subject: use ast_calloc instead of malloc+memset and remove some unnecessary initializations X-Git-Tag: 1.4.0-beta1~2402 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df09af8ee3e2d2debfd4922ad0ef6db37141fdca;p=thirdparty%2Fasterisk.git use ast_calloc instead of malloc+memset and remove some unnecessary initializations git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@13453 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/sched.c b/sched.c index eafe292c5b..effd6d8105 100644 --- a/sched.c +++ b/sched.c @@ -74,18 +74,13 @@ struct sched_context { struct sched_context *sched_context_create(void) { struct sched_context *tmp; - tmp = malloc(sizeof(struct sched_context)); - if (tmp) { - memset(tmp, 0, sizeof(struct sched_context)); - ast_mutex_init(&tmp->lock); - tmp->eventcnt = 1; - tmp->schedcnt = 0; - tmp->schedq = NULL; -#ifdef SCHED_MAX_CACHE - tmp->schedc = NULL; - tmp->schedccnt = 0; -#endif - } + + if (!(tmp = ast_calloc(1, sizeof(*tmp)))) + return NULL; + + ast_mutex_init(&tmp->lock); + tmp->eventcnt = 1; + return tmp; }