Imported Upstream version 0.63.0
[hcoop/debian/courier-authlib.git] / libltdl / libltdl / lt__alloc.h
CommitLineData
8d138742
CE
1/* lt__alloc.h -- internal memory management interface
2
3 Copyright (C) 2004 Free Software Foundation, Inc.
4 Written by Gary V. Vaughan, 2004
5
6 NOTE: The canonical source of this file is maintained with the
7 GNU Libtool package. Report bugs to bug-libtool@gnu.org.
8
9GNU Libltdl is free software; you can redistribute it and/or
10modify it under the terms of the GNU Lesser General Public
11License as published by the Free Software Foundation; either
12version 2 of the License, or (at your option) any later version.
13
14As a special exception to the GNU Lesser General Public License,
15if you distribute this file as part of a program or library that
16is built using GNU Libtool, you may include this file under the
17same distribution terms that you use for the rest of that program.
18
19GNU Libltdl is distributed in the hope that it will be useful,
20but WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22GNU Lesser General Public License for more details.
23
24You should have received a copy of the GNU Lesser General Public
25License along with GNU Libltdl; see the file COPYING.LIB. If not, a
26copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
27or obtained by writing to the Free Software Foundation, Inc.,
2851 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29*/
30
31#if !defined(LT__ALLOC_H)
32#define LT__ALLOC_H 1
33
34#include "lt_system.h"
35
36LT_BEGIN_C_DECLS
37
38#define MALLOC(tp, n) (tp*) lt__malloc((n) * sizeof(tp))
39#define REALLOC(tp, mem, n) (tp*) lt__realloc((mem), (n) * sizeof(tp))
40#define FREE(mem) LT_STMT_START { \
41 if (mem) { free ((void *)mem); mem = NULL; } } LT_STMT_END
42#define MEMREASSIGN(p, q) LT_STMT_START { \
43 if ((p) != (q)) { if (p) free (p); (p) = (q); (q) = 0; } \
44 } LT_STMT_END
45
46/* If set, this function is called when memory allocation has failed. */
47LT_SCOPE void (*lt__alloc_die) (void);
48
49LT_SCOPE void *lt__malloc (size_t n);
50LT_SCOPE void *lt__zalloc (size_t n);
51LT_SCOPE void *lt__realloc (void *mem, size_t n);
52LT_SCOPE void *lt__memdup (void const *mem, size_t n);
53
54LT_SCOPE char *lt__strdup (const char *string);
55
56LT_END_C_DECLS
57
58#endif /*!defined(LT__ALLOC_H)*/