refactoring

This commit is contained in:
Devaev Maxim
2021-03-28 22:48:17 +03:00
parent 181231f3ff
commit 01bc0529e7
4 changed files with 77 additions and 41 deletions

View File

@@ -46,36 +46,6 @@
#define ARRAY_LEN(_array) (sizeof(_array) / sizeof(_array[0]))
#define LIST_ITERATE(_first, _item, ...) { \
for (__typeof__(_first) _item = _first; _item;) { \
__typeof__(_first) _next = _item->next; \
__VA_ARGS__ \
_item = _next; \
} \
}
#define LIST_APPEND(_first, _item) { \
if (_first == NULL) { \
_first = _item; \
} else { \
__typeof__(_first) _last = _first; \
for (; _last->next; _last = _last->next); \
_item->prev = _last; \
_last->next = _item; \
} \
}
#define LIST_REMOVE(_first, _item) { \
if (_item->prev == NULL) { \
_first = _item->next; \
} else { \
_item->prev->next = _item->next; \
} \
if (_item->next != NULL) { \
_item->next->prev = _item->prev; \
} \
}
INLINE const char *bool_to_string(bool flag) {
return (flag ? "true" : "false");