]> git.sur5r.net Git - i3/i3/blob - i3bar/include/util.h
2e55e114f7dcd8604961468d60941f32d3254bea
[i3/i3] / i3bar / include / util.h
1 #ifndef UTIL_H_
2 #define UTIL_H_
3
4 /* Securely free p */
5 #define FREE(p) do { \
6         if (p != NULL) { \
7                 free(p); \
8                 p = NULL; \
9         } \
10 } while (0)
11
12 /* Securely fee single-linked list */
13 #define FREE_LIST(l, type) do { \
14         type* FREE_LIST_TMP; \
15         while (l != NULL) { \
16                 FREE_LIST_TMP = l; \
17                 free(l); \
18                 l = l->next; \
19         } \
20 } while (0)
21
22 #endif