Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Dec 2014 06:10:48 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r275595 - head/cddl/compat/opensolaris/misc
Message-ID:  <201412080610.sB86AmPV096410@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon Dec  8 06:10:47 2014
New Revision: 275595
URL: https://svnweb.freebsd.org/changeset/base/275595

Log:
  Use calloc() instead of malloc() + bzero().  This also gets rid of a warning
  because bzero is defined by strings.h which is not included in thread_pool.c.
  
  MFC after:	2 weeks

Modified:
  head/cddl/compat/opensolaris/misc/thread_pool.c

Modified: head/cddl/compat/opensolaris/misc/thread_pool.c
==============================================================================
--- head/cddl/compat/opensolaris/misc/thread_pool.c	Mon Dec  8 06:04:42 2014	(r275594)
+++ head/cddl/compat/opensolaris/misc/thread_pool.c	Mon Dec  8 06:10:47 2014	(r275595)
@@ -233,12 +233,11 @@ tpool_create(uint_t min_threads, uint_t 
 		return (NULL);
 	}
 
-	tpool = malloc(sizeof (*tpool));
+	tpool = calloc(1, sizeof (*tpool));
 	if (tpool == NULL) {
 		errno = ENOMEM;
 		return (NULL);
 	}
-	bzero(tpool, sizeof(*tpool));
 	(void) pthread_mutex_init(&tpool->tp_mutex, NULL);
 	(void) pthread_cond_init(&tpool->tp_busycv, NULL);
 	(void) pthread_cond_init(&tpool->tp_workcv, NULL);
@@ -267,9 +266,8 @@ tpool_dispatch(tpool_t *tpool, void (*fu
 {
 	tpool_job_t *job;
 
-	if ((job = malloc(sizeof (*job))) == NULL)
+	if ((job = calloc(1, sizeof (*job))) == NULL)
 		return (-1);
-	bzero(job, sizeof(*job));
 	job->tpj_next = NULL;
 	job->tpj_func = func;
 	job->tpj_arg = arg;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412080610.sB86AmPV096410>