9.0
general documentation
Loading...
Searching...
No Matches
bft_mem.h
Go to the documentation of this file.
1
#ifndef __BFT_MEM_H__
2
#define __BFT_MEM_H__
3
4
/*============================================================================
5
* Legacy memory allocation wrappers with optional tracing
6
*============================================================================*/
7
8
/*
9
This file is part of code_saturne, a general-purpose CFD tool.
10
11
Copyright (C) 1998-2025 EDF S.A.
12
13
This program is free software; you can redistribute it and/or modify it under
14
the terms of the GNU General Public License as published by the Free Software
15
Foundation; either version 2 of the License, or (at your option) any later
16
version.
17
18
This program is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21
details.
22
23
You should have received a copy of the GNU General Public License along with
24
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25
Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
*/
27
28
/*----------------------------------------------------------------------------*/
29
30
#include "
base/cs_defs.h
"
31
32
/*----------------------------------------------------------------------------*/
33
34
/* Local headers */
35
36
#include "
base/cs_mem.h
"
37
38
/*-----------------------------------------------------------------------------*/
39
40
BEGIN_C_DECLS
41
42
/*============================================================================
43
* Public macros
44
*============================================================================*/
45
46
/*
47
* Allocate memory for _ni items of type _type.
48
*
49
* This macro calls bft_mem_malloc(), automatically setting the
50
* allocated variable name and source file name and line arguments.
51
*
52
* parameters:
53
* _ptr --> pointer to allocated memory.
54
* _ni <-- number of items.
55
* _type <-- element type.
56
*/
57
58
#define BFT_MALLOC(_ptr, _ni, _type) \
59
_ptr = (_type *) cs_mem_malloc(_ni, sizeof(_type), \
60
#_ptr, __FILE__, __LINE__)
61
62
/*
63
* Reallocate memory for _ni items of type _type.
64
*
65
* This macro calls bft_mem_realloc(), automatically setting the
66
* allocated variable name and source file name and line arguments.
67
*
68
* parameters:
69
* _ptr <-> pointer to allocated memory.
70
* _ni <-- number of items.
71
* _type <-- element type.
72
*/
73
74
#define BFT_REALLOC(_ptr, _ni, _type) \
75
_ptr = (_type *) cs_mem_realloc(_ptr, _ni, sizeof(_type), \
76
#_ptr, __FILE__, __LINE__)
77
78
/*
79
* Free allocated memory.
80
*
81
* This macro calls bft_mem_free(), automatically setting the
82
* allocated variable name and source file name and line arguments.
83
*
84
* The freed pointer is set to NULL to avoid accidental reuse.
85
*
86
* parameters:
87
* _ptr <-> pointer to allocated memory.
88
*/
89
90
#define BFT_FREE(_ptr) \
91
cs_mem_free(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
92
93
/*----------------------------------------------------------------------------*/
94
95
END_C_DECLS
96
97
#endif
/* __BFT_MEM_H__ */
cs_defs.h
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition
cs_defs.h:542
END_C_DECLS
#define END_C_DECLS
Definition
cs_defs.h:543
cs_mem.h
src
bft
bft_mem.h
Generated on
for code_saturne by
1.14.0