aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2014-12-08 06:10:47 +0000
committerXin LI <delphij@FreeBSD.org>2014-12-08 06:10:47 +0000
commitbde3a4ec392b9c1b0e8764af583782500d4271d9 (patch)
tree40ae615d9dc7a05f741313e157ee9f218d851b8f
parentc2161091ad3723e6b6bf7a6bd982bd8a5ab5dda8 (diff)
downloadsrc-bde3a4ec392b9c1b0e8764af583782500d4271d9.tar.gz
src-bde3a4ec392b9c1b0e8764af583782500d4271d9.zip
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
Notes
Notes: svn path=/head/; revision=275595
-rw-r--r--cddl/compat/opensolaris/misc/thread_pool.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/cddl/compat/opensolaris/misc/thread_pool.c b/cddl/compat/opensolaris/misc/thread_pool.c
index a6a834fb2bbd..6ae0055afceb 100644
--- a/cddl/compat/opensolaris/misc/thread_pool.c
+++ b/cddl/compat/opensolaris/misc/thread_pool.c
@@ -233,12 +233,11 @@ tpool_create(uint_t min_threads, uint_t max_threads, uint_t linger,
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 (*func)(void *), void *arg)
{
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;