thr_attr_destroy.c revision 22315
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
31541Srgrimes * All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by John Birrell.
161541Srgrimes * 4. Neither the name of the author nor the names of any co-contributors
171541Srgrimes *    may be used to endorse or promote products derived from this software
181541Srgrimes *    without specific prior written permission.
191541Srgrimes *
201541Srgrimes * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
211541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
221541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
231541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
241541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
251541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
261541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
271541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
281541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2914511Shsu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
301541Srgrimes * SUCH DAMAGE.
311541Srgrimes *
32116182Sobrien */
33116182Sobrien#include <stdlib.h>
34116182Sobrien#include <errno.h>
351541Srgrimes#ifdef _THREAD_SAFE
361541Srgrimes#include <pthread.h>
371541Srgrimes#include "pthread_private.h"
381541Srgrimes
3931778Seivindint pthread_attr_destroy(pthread_attr_t *attr)
40111899Sdas{
411541Srgrimes	int	ret;
421541Srgrimes
4391140Stanimura	/* Check for invalid arguments: */
4491140Stanimura	if (attr == NULL || *attr == NULL)
4591140Stanimura		/* Invalid argument: */
46130892Sphk		ret = EINVAL;
47130344Sphk	else {
4824207Sbde		/* Free the memory allocated to the attribute object: */
4924207Sbde		free(*attr);
50130892Sphk
511541Srgrimes		/*
521541Srgrimes		 * Leave the attribute pointer NULL now that the memory
531541Srgrimes		 * has been freed:
5424131Sbde		 */
5529354Speter		*attr = NULL;
561541Srgrimes		ret = 0;
571541Srgrimes	}
583308Sphk	return(ret);
5949536Sphk}
601541Srgrimes#endif
6169774Sphk