thr_attr_destroy.c revision 256281
1321369Sdim/*
2249259Sdim * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
3353358Sdim * All rights reserved.
4353358Sdim *
5353358Sdim * Redistribution and use in source and binary forms, with or without
6249259Sdim * modification, are permitted provided that the following conditions
7249259Sdim * are met:
8249259Sdim * 1. Redistributions of source code must retain the above copyright
9249259Sdim *    notice, this list of conditions and the following disclaimer.
10249259Sdim * 2. Redistributions in binary form must reproduce the above copyright
11249259Sdim *    notice, this list of conditions and the following disclaimer in the
12249259Sdim *    documentation and/or other materials provided with the distribution.
13249259Sdim * 3. Neither the name of the author nor the names of any co-contributors
14249259Sdim *    may be used to endorse or promote products derived from this software
15249259Sdim *    without specific prior written permission.
16249259Sdim *
17249259Sdim * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
18249259Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19249259Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20314564Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21314564Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22249259Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23249259Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24249259Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25249259Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26314564Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27249259Sdim * SUCH DAMAGE.
28280031Sdim *
29249259Sdim * $FreeBSD: stable/10/lib/libkse/thread/thr_attr_destroy.c 174689 2007-12-16 23:29:57Z deischen $
30321369Sdim */
31249259Sdim#include "namespace.h"
32249259Sdim#include <stdlib.h>
33249259Sdim#include <errno.h>
34249259Sdim#include <pthread.h>
35249259Sdim#include "un-namespace.h"
36249259Sdim#include "thr_private.h"
37249259Sdim
38280031Sdim__weak_reference(_pthread_attr_destroy, pthread_attr_destroy);
39280031Sdim
40249259Sdimint
41249259Sdim_pthread_attr_destroy(pthread_attr_t *attr)
42296417Sdim{
43249259Sdim	int	ret;
44249259Sdim
45249259Sdim	/* Check for invalid arguments: */
46249259Sdim	if (attr == NULL || *attr == NULL)
47296417Sdim		/* Invalid argument: */
48249259Sdim		ret = EINVAL;
49249259Sdim	else {
50249259Sdim		/* Free the memory allocated to the attribute object: */
51249259Sdim		free(*attr);
52249259Sdim
53249259Sdim		/*
54296417Sdim		 * Leave the attribute pointer NULL now that the memory
55249259Sdim		 * has been freed:
56314564Sdim		 */
57314564Sdim		*attr = NULL;
58314564Sdim		ret = 0;
59249259Sdim	}
60249259Sdim	return(ret);
61249259Sdim}
62249259Sdim