memory.h
Go to the documentation of this file.
1 #ifndef NVIM_MEMORY_H
2 #define NVIM_MEMORY_H
3 
4 #include <stdbool.h> // for bool
5 #include <stdint.h> // for uint8_t
6 #include <stddef.h> // for size_t
7 #include <time.h> // for time_t
8 
10 typedef void *(*MemMalloc)(size_t);
11 
13 typedef void (*MemFree)(void *);
14 
16 typedef void *(*MemCalloc)(size_t, size_t);
17 
19 typedef void *(*MemRealloc)(void *, size_t);
20 
21 #ifdef UNIT_TESTING
22 extern MemMalloc mem_malloc;
24 
26 extern MemFree mem_free;
27 
29 extern MemCalloc mem_calloc;
30 
32 extern MemRealloc mem_realloc;
33 #endif
34 
35 #ifdef EXITFREE
36 extern bool entered_free_all_mem;
38 #endif
39 
40 #ifdef INCLUDE_GENERATED_DECLARATIONS
41 # include "memory.h.generated.h"
42 #endif
43 
44 #define XFREE_CLEAR(ptr) \
45  do { \
46  /* Take the address to avoid double evaluation. #1375 */ \
47  void **ptr_ = (void **)&(ptr); \
48  xfree(*ptr_); \
49  /* coverity[dead-store] */ \
50  *ptr_ = NULL; \
51  (void)(*ptr_); \
52  } while (0)
53 
54 #endif // NVIM_MEMORY_H
void(* MemFree)(void *)
free() function signature
Definition: memory.h:13
void *(* MemCalloc)(size_t, size_t)
calloc() function signature
Definition: memory.h:16
void *(* MemMalloc)(size_t)
malloc() function signature
Definition: memory.h:10
void *(* MemRealloc)(void *, size_t)
realloc() function signature
Definition: memory.h:19