1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1992-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _MULTIMEDIA_LIBAUDIO_IMPL_H
28 #define	_MULTIMEDIA_LIBAUDIO_IMPL_H
29 
30 #include <malloc.h>
31 #include <unistd.h>
32 #include <stdlib.h>
33 #include <sys/types.h>
34 #include <libaudio.h>
35 #include <archdep.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * Useful defines
43  *
44  * CALLOC - allocate memory and clear it
45  *		foo = CALLOC(15, char *);		-- alloc 15 ptrs
46  *
47  * MALLOC - allocate memory
48  *		foo = MALLOC(struct foobar);		-- alloc 1 foobar
49  *
50  * REALLOC - re-allocate a larger amount of memory
51  *		foo = REALLOC(foo, 10, struct foo);	-- extend to 10 foos
52  *
53  * FREE - de-allocate memory
54  *
55  * NOTE: These routines all operate on objects they can take the size of,
56  *	 rather than byte counts.
57  *
58  *
59  * XXX - the (long) in the following defines is used to make
60  * XXX   lint shut up about pointer alignment problems.
61  */
62 #define	MALLOC(type)	\
63 	(type *)(long)malloc(sizeof (type))
64 #define	CALLOC(number, type) \
65 	(type *)(long)calloc((unsigned)(number), sizeof (type))
66 #define	REALLOC(ptr, number, type) \
67 	(type *)(long)realloc((char *)(ptr), (unsigned)(number) * sizeof (type))
68 #define	FREE(ptr)	\
69 	(void) free((char *)(ptr))
70 
71 /*
72  * START_C_FUNC - declare this function with C linkage
73  * END_C_FUNC - put at the end of the function
74  */
75 #define	START_C_FUNC	extern "C" {
76 #define	END_C_FUNC	}
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* !_MULTIMEDIA_LIBAUDIO_IMPL_H */
83