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