FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_malloc.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
5 
6 #ifndef HECMW_MALLOC_INCLUDED
7 #define HECMW_MALLOC_INCLUDED
8 
9 #include <stdlib.h>
10 #include <string.h>
11 #include <stdio.h>
12 
13 #ifdef HECMW_MALLOC
14 #define HECMW_malloc(size) HECMW_malloc_(size, __FILE__, __LINE__)
15 #define HECMW_calloc(nmemb, size) HECMW_calloc_(nmemb, size, __FILE__, __LINE__)
16 #define HECMW_realloc(ptr, size) HECMW_realloc_(ptr, size, __FILE__, __LINE__)
17 #define HECMW_strdup(s) HECMW_strdup_(s, __FILE__, __LINE__)
18 #define HECMW_free(ptr) HECMW_free_(ptr, __FILE__, __LINE__)
19 #else
20 #define HECMW_malloc(size) malloc(size)
21 #define HECMW_calloc(nmemb, size) calloc(nmemb, size)
22 #define HECMW_realloc(ptr, size) realloc(ptr, size)
23 #define HECMW_strdup(s) strdup(s)
24 #define HECMW_free(ptr) free(ptr)
25 #endif
26 
27 extern void *HECMW_malloc_(size_t size, char *file, int line);
28 
29 extern void *HECMW_calloc_(size_t nmemb, size_t size, char *file, int line);
30 
31 extern void *HECMW_realloc_(void *ptr, size_t size, char *file, int line);
32 
33 extern char *HECMW_strdup_(const char *s, char *file, int line);
34 
35 extern void HECMW_free_(void *ptr, char *file, int line);
36 
37 extern int HECMW_check_memleak(void);
38 
39 extern long HECMW_get_memsize(void);
40 
41 extern void HECMW_set_autocheck_memleak(int flag);
42 
43 extern int HECMW_list_meminfo(FILE *fp);
44 
45 #endif
HECMW_list_meminfo
int HECMW_list_meminfo(FILE *fp)
Definition: hecmw_malloc.c:121
HECMW_check_memleak
int HECMW_check_memleak(void)
Definition: hecmw_malloc.c:138
HECMW_strdup_
char * HECMW_strdup_(const char *s, char *file, int line)
Definition: hecmw_malloc.c:249
malloc_info::file
char * file
Definition: hecmw_malloc.c:20
malloc_info::line
int line
Definition: hecmw_malloc.c:21
malloc_info::ptr
void * ptr
Definition: hecmw_malloc.c:18
HECMW_malloc_
void * HECMW_malloc_(size_t size, char *file, int line)
Definition: hecmw_malloc.c:179
HECMW_calloc_
void * HECMW_calloc_(size_t nmemb, size_t size, char *file, int line)
Definition: hecmw_malloc.c:194
HECMW_free_
void HECMW_free_(void *ptr, char *file, int line)
Definition: hecmw_malloc.c:170
HECMW_get_memsize
long HECMW_get_memsize(void)
Definition: hecmw_malloc.c:168
HECMW_set_autocheck_memleak
void HECMW_set_autocheck_memleak(int flag)
Definition: hecmw_malloc.c:136
HECMW_realloc_
void * HECMW_realloc_(void *ptr, size_t size, char *file, int line)
Definition: hecmw_malloc.c:209
malloc_info::size
size_t size
Definition: hecmw_malloc.c:19