|
Code_Saturne
CFD tool
|
#include "ecs_def.h"
Go to the source code of this file.
Macros | |
| #define | ECS_MALLOC(_ptr, _ni, _type) |
| #define | ECS_REALLOC(_ptr, _ni, _type) |
| Reallocate memory for _ni elements of type _type. More... | |
| #define | ECS_FREE(_ptr) _ptr = ecs_mem_free(_ptr, #_ptr, __FILE__, __LINE__) |
| Free allocated memory. More... | |
| #define | ECS_MEMALIGN(_ptr, _align, _ni, _type) |
Functions | |
| void | ecs_mem_init (const char *log_file_name) |
| Initialize memory handling. More... | |
| void | ecs_mem_end (void) |
| End memory handling. More... | |
| int | ecs_mem_initialized (void) |
| Indicates if ecs_mem_...() functions are initialized. More... | |
| void * | ecs_mem_malloc (size_t ni, size_t size, const char *var_name, const char *file_name, int line_num) |
| Allocate memory for ni elements of size bytes. More... | |
| void * | ecs_mem_realloc (void *ptr, size_t ni, size_t size, const char *var_name, const char *file_name, int line_num) |
| Reallocate memory for ni elements of size bytes. More... | |
| void * | ecs_mem_free (void *ptr, const char *var_name, const char *file_name, int line_num) |
| Free allocated memory. More... | |
| size_t | ecs_mem_size_current (void) |
| Return current theoretical dynamic memory allocated. More... | |
| size_t | ecs_mem_size_max (void) |
| Return maximum theoretical dynamic memory allocated. More... | |
| ECS_FREE | ( | _ptr | ) | _ptr = ecs_mem_free(_ptr, #_ptr, __FILE__, __LINE__) |
Free allocated memory.
This macro calls ecs_mem_free(), automatically setting the allocated variable name and source file name and line arguments.
The freed pointer is set to NULL to avoid accidental reuse.
| [in,out] | _ptr | pointer to allocated memory. |
| #define ECS_MALLOC | ( | _ptr, | |
| _ni, | |||
| _type | |||
| ) |
| #define ECS_MEMALIGN | ( | _ptr, | |
| _align, | |||
| _ni, | |||
| _type | |||
| ) |
| ECS_REALLOC | ( | _ptr, | |
| _ni, | |||
| _type | |||
| ) |
Reallocate memory for _ni elements of type _type.
This macro calls ecs_mem_realloc(), automatically setting the allocated variable name and source file name and line arguments.
| [in,out] | _ptr | pointer to allocated memory. |
| [in] | _ni | number of elements. |
| [in] | _type | element type. |
| void ecs_mem_end | ( | void | ) |
End memory handling.
This function should be called after all other ecs_mem_...() functions. In case of memory allocation logging, it writes final information to the log file and closes is.
| void* ecs_mem_free | ( | void * | ptr, |
| const char * | var_name, | ||
| const char * | file_name, | ||
| int | line_num | ||
| ) |
Free allocated memory.
This function calls free(), but adds tracing capabilities, and automatically calls the ecs_error() errorhandler if it fails to free the corresponding memory. In case of a NULL pointer argument, the function simply returns.
| [in] | ptr | pointer to previous memory location (if NULL, ecs_alloc() called). |
| [in] | var_name | allocated variable name string |
| [in] | file_name | name of calling source file |
| [in] | line_num | line number in calling source file |
| void ecs_mem_init | ( | const char * | log_file_name | ) |
Initialize memory handling.
This function should be called before any other ecs_mem_...() function. To activate memory allocation logging, a logfile name should be given as an argument. The resulting file will be a regular, local file. If this file cannot be opened for some reason, logging is silently de-activated.
| log_file_name | name of optional log_file (if NULL, no log). |
| int ecs_mem_initialized | ( | void | ) |
Indicates if ecs_mem_...() functions are initialized.
| void* ecs_mem_malloc | ( | size_t | ni, |
| size_t | size, | ||
| const char * | var_name, | ||
| const char * | file_name, | ||
| int | line_num | ||
| ) |
Allocate memory for ni elements of size bytes.
This function calls malloc(), but adds tracing capabilities, and automatically calls the ecs_error() errorhandler if it fails to allocate the required memory.
| [in] | ni | number of elements. |
| [in] | size | element size. |
| [in] | var_name | allocated variable name string. |
| [in] | file_name | name of calling source file. |
| [in] | line_num | line number in calling source file. |
| void* ecs_mem_realloc | ( | void * | ptr, |
| size_t | ni, | ||
| size_t | size, | ||
| const char * | var_name, | ||
| const char * | file_name, | ||
| int | line_num | ||
| ) |
Reallocate memory for ni elements of size bytes.
This function calls realloc(), but adds tracing capabilities, and automatically calls the ecs_error() errorhandler if it fails to allocate the required memory.
| [in] | ptr | pointer to previous memory location (if NULL, ecs_alloc() called). |
| [in] | ni | number of elements. |
| [in] | size | element size. |
| [in] | var_name | allocated variable name string. |
| [in] | file_name | name of calling source file. |
| [in] | line_num | line number in calling source file. |

| size_t ecs_mem_size_current | ( | void | ) |
Return current theoretical dynamic memory allocated.
| size_t ecs_mem_size_max | ( | void | ) |
Return maximum theoretical dynamic memory allocated.
1.8.13