Thread (290 messages) flat view 290 messages, 13 authors, 2022-04-12

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

From: Dmitry Kozlyuk <hidden>
Date: 2021-06-18 22:48:42

2021-06-18 14:41 (UTC-0700), Narcisa Ana Maria Vasile:
On Wed, Jun 09, 2021 at 02:04:09AM +0300, Dmitry Kozlyuk wrote:
quoted
2021-06-04 16:44 (UTC-0700), Narcisa Ana Maria Vasile:
[...]
quoted
quoted
+
+	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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help