STASIS
A pipeline delivery generator
Loading...
Searching...
No Matches
src
lib
core
include
core_mem.h
Go to the documentation of this file.
1
2
#ifndef STASIS_CORE_MEM_H
3
#define STASIS_CORE_MEM_H
4
5
#include "
environment.h
"
6
#include "
strlist.h
"
7
8
#define guard_runtime_free(X) do { runtime_free(X); (X) = NULL; } while (0)
9
#define guard_strlist_free(X) do { strlist_free(X); (*X) = NULL; } while (0)
10
#define guard_free(X) do { free(X); (X) = NULL; } while (0)
11
#define ARRAY_COUNT(ARR) sizeof((ARR)) / sizeof((*ARR))
12
#define guard_array_free_by_count(ARR, COUNT) do { \
13
for (size_t ARR_I = 0; (ARR) && ARR_I < (COUNT); ARR_I++) { \
14
guard_free((ARR)[ARR_I]); \
15
} \
16
guard_free((ARR)); \
17
} while (0)
18
#define guard_array_free(ARR) do { \
19
for (size_t ARR_I = 0; ARR && ARR[ARR_I] != NULL; ARR_I++) { \
20
guard_free(ARR[ARR_I]); \
21
} \
22
guard_free(ARR); \
23
} while (0)
24
25
#define guard_array_n_free(ARR, LEN) do { \
26
for (size_t ARR_I = 0; ARR && ARR_I < LEN ; ARR_I++) { \
27
guard_free(ARR[ARR_I]); \
28
} \
29
guard_free(ARR); \
30
} while (0)
31
32
#endif
//STASIS_CORE_MEM_H
environment.h
strlist.h
Generated by
1.13.2