SST  9.0.0
StructuralSimulationToolkit
lt__alloc.h
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 
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.
13 
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.
18 
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.
23 
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
29 */
30 
31 #if !defined(LT__ALLOC_H)
32 #define LT__ALLOC_H 1
33 
34 #include "lt_system.h"
35 
36 LT_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. */
47 LT_SCOPE void (*lt__alloc_die) (void);
48 
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);
53 
54 LT_SCOPE char *lt__strdup (const char *string);
55 
56 LT_END_C_DECLS
57 
58 #endif /*!defined(LT__ALLOC_H)*/