mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 13:44:32 +02:00
pthread: Cleanups for attr init/destroy
* Zero all fields of the attr structure when initializing * Can implement pthread_attr_destroy() by calling pthread_attr_init()
This commit is contained in:
@@ -728,6 +728,7 @@ int pthread_mutexattr_init(pthread_mutexattr_t *attr)
|
|||||||
if (!attr) {
|
if (!attr) {
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
memset(attr, 0, sizeof(*attr));
|
||||||
attr->type = PTHREAD_MUTEX_NORMAL;
|
attr->type = PTHREAD_MUTEX_NORMAL;
|
||||||
attr->is_initialized = 1;
|
attr->is_initialized = 1;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -769,6 +770,7 @@ int pthread_attr_init(pthread_attr_t *attr)
|
|||||||
{
|
{
|
||||||
if (attr) {
|
if (attr) {
|
||||||
/* Nothing to allocate. Set everything to default */
|
/* Nothing to allocate. Set everything to default */
|
||||||
|
memset(attr, 0, sizeof(*attr));
|
||||||
attr->stacksize = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
attr->stacksize = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
||||||
attr->detachstate = PTHREAD_CREATE_JOINABLE;
|
attr->detachstate = PTHREAD_CREATE_JOINABLE;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -778,13 +780,8 @@ int pthread_attr_init(pthread_attr_t *attr)
|
|||||||
|
|
||||||
int pthread_attr_destroy(pthread_attr_t *attr)
|
int pthread_attr_destroy(pthread_attr_t *attr)
|
||||||
{
|
{
|
||||||
if (attr) {
|
/* Nothing to deallocate. Reset everything to default */
|
||||||
/* Nothing to deallocate. Reset everything to default */
|
return pthread_attr_init(attr);
|
||||||
attr->stacksize = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
|
||||||
attr->detachstate = PTHREAD_CREATE_JOINABLE;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
|
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
|
||||||
|
Reference in New Issue
Block a user