]> git.ipfire.org Git - thirdparty/bash.git/blame - xmalloc.h
Bash-5.2 patch 26: fix typo when specifying readline's custom color prefix
[thirdparty/bash.git] / xmalloc.h
CommitLineData
f73dda09
JA
1/* xmalloc.h -- defines for the `x' memory allocation functions */
2
8868edaf 3/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
f73dda09
JA
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
3185942a
JA
7 Bash is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
f73dda09 11
3185942a
JA
12 Bash is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
f73dda09 16
3185942a
JA
17 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
19*/
f73dda09
JA
20
21#if !defined (_XMALLOC_H_)
22#define _XMALLOC_H_
23
24#include "stdc.h"
25#include "bashansi.h"
26
27/* Generic pointer type. */
28#ifndef PTR_T
29
30#if defined (__STDC__)
31# define PTR_T void *
32#else
33# define PTR_T char *
34#endif
35
36#endif /* PTR_T */
37
38/* Allocation functions in xmalloc.c */
8868edaf
CR
39extern PTR_T xmalloc PARAMS((size_t));
40extern PTR_T xrealloc PARAMS((void *, size_t));
41extern void xfree PARAMS((void *));
f73dda09 42
7117c2d2 43#if defined(USING_BASH_MALLOC) && !defined (DISABLE_MALLOC_WRAPPERS)
8868edaf
CR
44extern PTR_T sh_xmalloc PARAMS((size_t, const char *, int));
45extern PTR_T sh_xrealloc PARAMS((void *, size_t, const char *, int));
46extern void sh_xfree PARAMS((void *, const char *, int));
f73dda09
JA
47
48#define xmalloc(x) sh_xmalloc((x), __FILE__, __LINE__)
49#define xrealloc(x, n) sh_xrealloc((x), (n), __FILE__, __LINE__)
50#define xfree(x) sh_xfree((x), __FILE__, __LINE__)
51
52#ifdef free
53#undef free
54#endif
55#define free(x) sh_xfree((x), __FILE__, __LINE__)
8868edaf
CR
56
57extern PTR_T sh_malloc PARAMS((size_t, const char *, int));
58
59#ifdef malloc
60#undef malloc
61#endif
62#define malloc(x) sh_malloc((x), __FILE__, __LINE__)
63
f73dda09
JA
64#endif /* USING_BASH_MALLOC */
65
66#endif /* _XMALLOC_H_ */