xref: /onnv-gate/usr/src/cmd/fm/eversholt/common/alloc.h (revision 5609:6c18074bcfad)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
54436Sstephh  * Common Development and Distribution License (the "License").
64436Sstephh  *  You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
224436Sstephh  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  *
250Sstevel@tonic-gate  * alloc.h -- public definitions for memory allocation module
260Sstevel@tonic-gate  *
270Sstevel@tonic-gate  */
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifndef	_ESC_COMMON_ALLOC_H
300Sstevel@tonic-gate #define	_ESC_COMMON_ALLOC_H
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate void alloc_init(void);
390Sstevel@tonic-gate void alloc_fini(void);
400Sstevel@tonic-gate void *alloc_realloc(void *ptr, size_t nbytes, const char *fname, int line);
410Sstevel@tonic-gate void *alloc_malloc(size_t nbytes, const char *fname, int line);
420Sstevel@tonic-gate void alloc_free(void *ptr, const char *fname, int line);
430Sstevel@tonic-gate char *alloc_strdup(const char *ptr, const char *fname, int line);
444436Sstephh void *alloc_xmalloc(size_t size);
454436Sstephh void alloc_xfree(void *ptr, size_t size);
460Sstevel@tonic-gate 
47*5609Scy152378 #ifdef DEBUG
48*5609Scy152378 
490Sstevel@tonic-gate #define	MALLOC(nbytes) alloc_malloc(nbytes, __FILE__, __LINE__)
500Sstevel@tonic-gate #define	REALLOC(ptr, nbytes) alloc_realloc(ptr, nbytes, __FILE__, __LINE__)
510Sstevel@tonic-gate #define	FREE(ptr) alloc_free(ptr, __FILE__, __LINE__)
520Sstevel@tonic-gate #define	STRDUP(ptr) alloc_strdup(ptr, __FILE__, __LINE__)
530Sstevel@tonic-gate 
54*5609Scy152378 #else
55*5609Scy152378 
56*5609Scy152378 #define	MALLOC(nbytes) alloc_malloc(nbytes, "???", __LINE__)
57*5609Scy152378 #define	REALLOC(ptr, nbytes) alloc_realloc(ptr, nbytes, "???", __LINE__)
58*5609Scy152378 #define	FREE(ptr) alloc_free(ptr, "???", __LINE__)
59*5609Scy152378 #define	STRDUP(ptr) alloc_strdup(ptr, "???", __LINE__)
60*5609Scy152378 
61*5609Scy152378 #endif
62*5609Scy152378 
630Sstevel@tonic-gate #ifdef	__cplusplus
640Sstevel@tonic-gate }
650Sstevel@tonic-gate #endif
660Sstevel@tonic-gate 
670Sstevel@tonic-gate #endif	/* _ESC_COMMON_ALLOC_H */
68