mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04: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:
parent
a6dea64106
commit
c6b2191643
@ -728,6 +728,7 @@ int pthread_mutexattr_init(pthread_mutexattr_t *attr)
|
||||
if (!attr) {
|
||||
return EINVAL;
|
||||
}
|
||||
memset(attr, 0, sizeof(*attr));
|
||||
attr->type = PTHREAD_MUTEX_NORMAL;
|
||||
attr->is_initialized = 1;
|
||||
return 0;
|
||||
@ -769,6 +770,7 @@ int pthread_attr_init(pthread_attr_t *attr)
|
||||
{
|
||||
if (attr) {
|
||||
/* Nothing to allocate. Set everything to default */
|
||||
memset(attr, 0, sizeof(*attr));
|
||||
attr->stacksize = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
||||
attr->detachstate = PTHREAD_CREATE_JOINABLE;
|
||||
return 0;
|
||||
@ -778,13 +780,8 @@ int pthread_attr_init(pthread_attr_t *attr)
|
||||
|
||||
int pthread_attr_destroy(pthread_attr_t *attr)
|
||||
{
|
||||
if (attr) {
|
||||
/* Nothing to deallocate. Reset everything to default */
|
||||
attr->stacksize = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
||||
attr->detachstate = PTHREAD_CREATE_JOINABLE;
|
||||
return 0;
|
||||
}
|
||||
return EINVAL;
|
||||
/* Nothing to deallocate. Reset everything to default */
|
||||
return pthread_attr_init(attr);
|
||||
}
|
||||
|
||||
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
|
||||
|
Loading…
Reference in New Issue
Block a user