9.2
general documentation
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-2026 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
* Public macros
40
*============================================================================*/
41
42
/*
43
* Allocate memory for _ni items of type _type.
44
*
45
* This macro calls bft_mem_malloc(), automatically setting the
46
* allocated variable name and source file name and line arguments.
47
*
48
* parameters:
49
* _ptr --> pointer to allocated memory.
50
* _ni <-- number of items.
51
* _type <-- element type.
52
*/
53
54
#define BFT_MALLOC(_ptr, _ni, _type) \
55
_ptr = (_type *) cs_mem_malloc(_ni, sizeof(_type), \
56
#_ptr, __FILE__, __LINE__)
57
58
/*
59
* Reallocate memory for _ni items of type _type.
60
*
61
* This macro calls bft_mem_realloc(), automatically setting the
62
* allocated variable name and source file name and line arguments.
63
*
64
* parameters:
65
* _ptr <-> pointer to allocated memory.
66
* _ni <-- number of items.
67
* _type <-- element type.
68
*/
69
70
#define BFT_REALLOC(_ptr, _ni, _type) \
71
_ptr = (_type *) cs_mem_realloc(_ptr, _ni, sizeof(_type), \
72
#_ptr, __FILE__, __LINE__)
73
74
/*
75
* Free allocated memory.
76
*
77
* This macro calls bft_mem_free(), automatically setting the
78
* allocated variable name and source file name and line arguments.
79
*
80
* The freed pointer is set to NULL to avoid accidental reuse.
81
*
82
* parameters:
83
* _ptr <-> pointer to allocated memory.
84
*/
85
86
#define BFT_FREE(_ptr) \
87
cs_mem_free(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
88
89
/*----------------------------------------------------------------------------*/
90
91
#endif
/* BFT_MEM_H */
cs_defs.h
cs_mem.h
src
bft
bft_mem.h
Generated on Mon Jul 6 2026 11:49:54 for code_saturne by
1.9.4