const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg)
{
- struct rte_thread_ctrl_params params = {
- .start_routine = start_routine,
- .arg = arg,
- };
+ struct rte_thread_ctrl_params *params;
unsigned int lcore_id;
rte_cpuset_t cpuset;
int cpu_found, ret;
- pthread_barrier_init(¶ms.configured, NULL, 2);
+ params = malloc(sizeof(*params));
+ if (!params)
+ return -1;
+
+ params->start_routine = start_routine;
+ params->arg = arg;
- ret = pthread_create(thread, attr, rte_thread_init, (void *)¶ms);
+ pthread_barrier_init(¶ms->configured, NULL, 2);
+
+ ret = pthread_create(thread, attr, rte_thread_init, (void *)params);
if (ret != 0)
return ret;
if (ret < 0)
goto fail;
- pthread_barrier_wait(¶ms.configured);
+ pthread_barrier_wait(¶ms->configured);
+ free(params);
return 0;
fail:
pthread_cancel(*thread);
pthread_join(*thread, NULL);
+ free(params);
return ret;
}