[dpdk-dev] [PATCH v9 06/10] eal: add thread lifetime management

Dmitry Kozlyuk dmitry.kozliuk at gmail.com
Sat Jun 19 00:48:36 CEST 2021


2021-06-18 14:41 (UTC-0700), Narcisa Ana Maria Vasile:
> On Wed, Jun 09, 2021 at 02:04:09AM +0300, Dmitry Kozlyuk wrote:
> > 2021-06-04 16:44 (UTC-0700), Narcisa Ana Maria Vasile:
[...]
> > > +
> > > +	HANDLE thread_handle = NULL;
> > > +	GROUP_AFFINITY thread_affinity;
> > > +	struct thread_routine_ctx *ctx = NULL;
> > > +
> > > +	ctx = calloc(1, sizeof(*ctx));  
> > 
> > Why use `calloc()` for a scalar?  
> 
> ctx is pointer to struct that holds the thread function pointer and its arguments.
> Did I misunderstand what you meant?

`calloc(size_t n, size_t size)` mainly exists for safe array allocations,
because multiplication in `malloc(n * size)` may overflow. You are allocating
a singular value, i. e. a scalar, so the choice of `calloc()` over `malloc()`
raises questions. Nevertheless, it is harmless and works correctly. Consider
it a nit.


More information about the dev mailing list