diff options
Diffstat (limited to 'lib/libc_r/uthread/uthread_attr_init.c')
| -rw-r--r-- | lib/libc_r/uthread/uthread_attr_init.c | 13 | 
1 files changed, 9 insertions, 4 deletions
| diff --git a/lib/libc_r/uthread/uthread_attr_init.c b/lib/libc_r/uthread/uthread_attr_init.c index 7dade978a48f..c64e29fed11c 100644 --- a/lib/libc_r/uthread/uthread_attr_init.c +++ b/lib/libc_r/uthread/uthread_attr_init.c @@ -41,11 +41,16 @@ int pthread_attr_init(pthread_attr_t *attr)  {  	int	ret;  	pthread_attr_t	pattr; -	if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL) { -		errno = ENOMEM; -		ret = -1; -	} else { + +	/* Allocate memory for the attribute object: */ +	if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL) +		/* Insufficient memory: */ +		ret = ENOMEM; +	else { +		/* Initialise the attribute object with the defaults: */  		memcpy(pattr, &pthread_attr_default, sizeof(struct pthread_attr)); + +		/* Return a pointer to the attribute object: */  		*attr = pattr;  		ret = 0;  	} | 
