Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 1 | /* Functions (currently) for use by the shell to do malloc debugging and |
| 2 | tracking. */ |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 3 | /* Copyright (C) 2001-2003 Free Software Foundation, Inc. |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 4 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 5 | This file is part of GNU Bash, the Bourne-Again SHell. |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 6 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 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. |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 11 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 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. |
| 16 | |
| 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 | */ |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 20 | |
| 21 | #ifndef _SH_MALLOC_H |
| 22 | #define _SH_MALLOC_H |
| 23 | |
| 24 | #ifndef __P |
| 25 | # if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) |
| 26 | # define __P(protos) protos |
| 27 | # else |
| 28 | # define __P(protos) () |
| 29 | # endif |
| 30 | #endif |
| 31 | |
| 32 | /* Generic pointer type. */ |
| 33 | #ifndef PTR_T |
| 34 | |
| 35 | #if defined (__STDC__) |
| 36 | # define PTR_T void * |
| 37 | #else |
| 38 | # define PTR_T char * |
| 39 | #endif |
| 40 | |
| 41 | #endif /* PTR_T */ |
| 42 | |
| 43 | |
| 44 | extern PTR_T sh_malloc __P((size_t, const char *, int)); |
| 45 | extern PTR_T sh_realloc __P((PTR_T, size_t, const char *, int)); |
| 46 | extern void sh_free __P((PTR_T, const char *, int)); |
| 47 | |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 48 | extern PTR_T sh_memalign __P((size_t, size_t, const char *, int)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 49 | |
| 50 | extern PTR_T sh_calloc __P((size_t, size_t, const char *, int)); |
| 51 | extern void sh_cfree __P((PTR_T, const char *, int)); |
| 52 | |
| 53 | extern PTR_T sh_valloc __P((size_t, const char *, int)); |
| 54 | |
| 55 | /* trace.c */ |
| 56 | extern int malloc_set_trace __P((int)); |
| 57 | extern void malloc_set_tracefp (); /* full prototype requires stdio.h */ |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 58 | extern void malloc_set_tracefn __P((char *, char *)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 59 | |
| 60 | /* table.c */ |
| 61 | extern void mregister_dump_table __P((void)); |
| 62 | extern void mregister_table_init __P((void)); |
| 63 | extern int malloc_set_register __P((int)); |
| 64 | |
| 65 | /* stats.c */ |
| 66 | extern void print_malloc_stats __P((char *)); |
| 67 | extern void fprint_malloc_stats (); /* full prototype requires stdio.h */ |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 68 | extern void trace_malloc_stats __P((char *, char *)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 69 | |
| 70 | #endif |