APPFS
Advanced practical programming for scientists
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
mshell.h
Go to the documentation of this file.
1 /* $Id: mshell.h,v 1.16 2014/03/03 16:44:16 bzfkocht Exp $ */
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
3 /* */
4 /* File....: mshell.h */
5 /* Name....: Memory Allocation Shell */
6 /* Author..: Thorsten Koch */
7 /* Copyright by Author, All rights reserved */
8 /* */
9 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10 /*
11  * Copyright (C) 2007-2014 by Thorsten Koch <koch@zib.de>
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public License
15  * as published by the Free Software Foundation; either version 3
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26  */
27 
28 #ifndef _MSHELL_H_
29 #define _MSHELL_H_
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*lint -sem( mem_malloc, nulterm(2), 1n > 0 && 2p, @P == malloc(1n)) */
36 extern void* mem_malloc(size_t, const char*, const int);
37 /*lint -sem( mem_calloc, nulterm(3), 1n > 0 && 2n > 0 && 3p, @P == malloc(1n * 2n)) */
38 extern void* mem_calloc(size_t, size_t, const char*, const int);
39 /*lint -sem( mem_realloc, custodial(1), nulterm(3), 1p > 0 && 2n > 0 && 3p, @P == malloc(2n)) */
40 extern void* mem_realloc(void*, size_t, const char*, const int);
41 /*lint -sem( mem_strdup, nulterm(1), nulterm(2), 1p > 0 && 2p > 0, @P == malloc(1P) && nulterm(@p)) */
42 extern char* mem_strdup(const char*, const char*, const int);
43 /*lint -sem( mem_free, custodial(1), nulterm(2), 1p > 0 && 2p) */
44 extern void mem_free(void*, const char*, const int);
45 
46 #ifndef _MSHELL_C_
47 
48 #ifdef strdup
49 #undef strdup
50 #endif /* strdup */
51 
52 /*lint -e652 -e683*/
53 #define malloc(a) mem_malloc((a), __FILE__, __LINE__)
54 #define calloc(a, b) mem_calloc((a), (b), __FILE__, __LINE__)
55 #define realloc(a, b) mem_realloc((a), (b), __FILE__, __LINE__)
56 #define strdup(a) mem_strdup((a), __FILE__, __LINE__)
57 #define free(a) mem_free((a), __FILE__, __LINE__)
58 /*line +e652 +e683*/
59 
60 #endif /* _MSHELL_C_ */
61 
62 #ifndef NO_MSHELL
63 
64 extern size_t mem_used(void);
65 extern void mem_maximum(FILE* fp);
66 extern void mem_display(FILE* fp);
67 extern void mem_check_x(const void* p, const char* file, const int line);
68 extern void mem_check_all_x(const char* file, const int line);
69 extern void mem_hide_x(void* p, const char* file, const int line);
70 
71 #define mem_check(a) mem_check_x(a, __FILE__, __LINE__)
72 #define mem_check_all() mem_check_all_x(__FILE__, __LINE__)
73 #define mem_hide(a) mem_hide_x(a, __FILE__, __LINE__)
74 
75 #else /* NO_MSHELL */
76 
77 #define mem_used()
78 #define mem_maximum(a)
79 #define mem_display(a)
80 #define mem_check(a)
81 #define mem_check_all()
82 #define mem_hide(a)
83 
84 #endif /* !NO_MSHELL */
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif /* _MSHELL_H_ */
91 
92 
int line
Definition: mshell.c:60
void mem_free(void *, const char *, const int)
Definition: mshell.c:322
void mem_maximum(FILE *fp)
Definition: mshell.c:373
void mem_display(FILE *fp)
Definition: mshell.c:380
void mem_check_x(const void *p, const char *file, const int line)
Definition: mshell.c:401
void * mem_calloc(size_t, size_t, const char *, const int)
Definition: mshell.c:223
void mem_hide_x(void *p, const char *file, const int line)
Definition: mshell.c:344
void * mem_realloc(void *, size_t, const char *, const int)
Definition: mshell.c:259
void mem_check_all_x(const char *file, const int line)
Definition: mshell.c:411
size_t mem_used(void)
Definition: mshell.c:368
void * mem_malloc(size_t, const char *, const int)
Definition: mshell.c:183
char * mem_strdup(const char *, const char *, const int)
Definition: mshell.c:307
char const * file
Definition: mshell.c:59