xmalloc.h

Go to the documentation of this file.
00001 /*
00002  * mplib - a library that enables you to edit ID3 tags
00003  *
00004  * Copyright (c) 2001,2002,2003,2004,2005 Stefan Podkowinski
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without 
00008  * modification, are permitted provided that the following conditions are met:
00009  *
00010  * * Redistributions of source code must retain the above copyright notice, this
00011  *   list of conditions and the following disclaimer.
00012  * * Redistributions in binary form must reproduce the above copyright notice,
00013  *   this list of conditions and the following disclaimer in the documentation
00014  *   and/or other materials provided with the distribution.
00015  * * Neither the name of the author nor the names of its contributors
00016  *   may be used to endorse or promote products derived from this software
00017  *   without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00023  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029  * POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 #ifndef __XMALLOC_H
00033 #define __XMALLOC_H
00034 
00035 /* __BEGIN_DECLS should be used at the beginning of your declarations,
00036    so that C++ compilers don't mangle their names.  Use __END_DECLS at
00037    the end of C declarations. */
00038 #undef __BEGIN_DECLS
00039 #undef __END_DECLS
00040 #ifdef __cplusplus
00041 # define __BEGIN_DECLS extern "C" {
00042 # define __END_DECLS }
00043 #else
00044 # define __BEGIN_DECLS /* empty */
00045 # define __END_DECLS /* empty */
00046 #endif
00047 
00048 
00049 #define XMALLOC(type) ((type *) xmalloc(sizeof(type)))
00050 #define XMALLOCD(type,descr) ((type *) xmallocd(sizeof(type),descr))
00051 #define XMALLOC0(type) ((type *) xmalloc0(sizeof(type)))
00052 #define XMALLOCD0(type,descr) ((type *) xmallocd0(sizeof(type),descr))
00053 
00054 __BEGIN_DECLS
00055 
00056 /* define XMALLOC_CHECK 1 */
00057 
00058 void *xmalloc(size_t);
00059 void *xmallocd(size_t, char*);
00060 void *xmalloc0(size_t);
00061 void *xmallocd0(size_t, char*);
00062 void *xrealloc(void *, size_t);
00063 void *xcalloc(size_t, size_t);
00064 void xfree(void*);
00065 #ifdef XMALLOC_CHECK
00066 void xprint_malloc_stat(void);
00067 #endif
00068 
00069 __END_DECLS
00070 
00071 #endif /* __XMALLOC_H */