00001 /* lt__alloc.h -- internal memory management interface 00002 00003 Copyright (C) 2004 Free Software Foundation, Inc. 00004 Written by Gary V. Vaughan, 2004 00005 00006 NOTE: The canonical source of this file is maintained with the 00007 GNU Libtool package. Report bugs to bug-libtool@gnu.org. 00008 00009 GNU Libltdl is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2 of the License, or (at your option) any later version. 00013 00014 As a special exception to the GNU Lesser General Public License, 00015 if you distribute this file as part of a program or library that 00016 is built using GNU Libtool, you may include this file under the 00017 same distribution terms that you use for the rest of that program. 00018 00019 GNU Libltdl is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU Lesser General Public License for more details. 00023 00024 You should have received a copy of the GNU Lesser General Public 00025 License along with GNU Libltdl; see the file COPYING.LIB. If not, a 00026 copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, 00027 or obtained by writing to the Free Software Foundation, Inc., 00028 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00029 */ 00030 00031 #if !defined(LT__ALLOC_H) 00032 #define LT__ALLOC_H 1 00033 00034 #include "lt_system.h" 00035 00036 LT_BEGIN_C_DECLS 00037 00038 #define MALLOC(tp, n) (tp*) lt__malloc((n) * sizeof(tp)) 00039 #define REALLOC(tp, mem, n) (tp*) lt__realloc((mem), (n) * sizeof(tp)) 00040 #define FREE(mem) LT_STMT_START { \ 00041 if (mem) { free ((void *)mem); mem = NULL; } } LT_STMT_END 00042 #define MEMREASSIGN(p, q) LT_STMT_START { \ 00043 if ((p) != (q)) { if (p) free (p); (p) = (q); (q) = 0; } \ 00044 } LT_STMT_END 00045 00046 /* If set, this function is called when memory allocation has failed. */ 00047 LT_SCOPE void (*lt__alloc_die) (void); 00048 00049 LT_SCOPE void *lt__malloc (size_t n); 00050 LT_SCOPE void *lt__zalloc (size_t n); 00051 LT_SCOPE void *lt__realloc (void *mem, size_t n); 00052 LT_SCOPE void *lt__memdup (void const *mem, size_t n); 00053 00054 LT_SCOPE char *lt__strdup (const char *string); 00055 00056 LT_END_C_DECLS 00057 00058 #endif