1
/* lt__alloc.h -- internal memory management interface
3
Copyright (C) 2004 Free Software Foundation, Inc.
4
Written by Gary V. Vaughan, 2004
6
NOTE: The canonical source of this file is maintained with the
7
GNU Libtool package. Report bugs to bug-libtool@gnu.org.
9
GNU Libltdl is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Lesser General Public
11
License as published by the Free Software Foundation; either
12
version 2 of the License, or (at your option) any later version.
14
As a special exception to the GNU Lesser General Public License,
15
if you distribute this file as part of a program or library that
16
is built using GNU Libtool, you may include this file under the
17
same distribution terms that you use for the rest of that program.
19
GNU Libltdl is distributed in the hope that it will be useful,
20
but WITHOUT ANY WARRANTY; without even the implied warranty of
21
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
GNU Lesser General Public License for more details.
24
You should have received a copy of the GNU Lesser General Public
25
License along with GNU Libltdl; see the file COPYING.LIB. If not, a
26
copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
27
or obtained by writing to the Free Software Foundation, Inc.,
28
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31
#if !defined(LT__ALLOC_H)
34
#include "lt_system.h"
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; } \
46
/* If set, this function is called when memory allocation has failed. */
47
LT_SCOPE void (*lt__alloc_die) (void);
49
LT_SCOPE void *lt__malloc (size_t n);
50
LT_SCOPE void *lt__zalloc (size_t n);
51
LT_SCOPE void *lt__realloc (void *mem, size_t n);
52
LT_SCOPE void *lt__memdup (void const *mem, size_t n);
54
LT_SCOPE char *lt__strdup (const char *string);
58
#endif /*!defined(LT__ALLOC_H)*/