diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2020-12-03 00:53:04 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2020-12-03 00:53:04 -0700 |
commit | c4cd1464e6f253a2d1d83ec93a16053c5a247b6f (patch) | |
tree | 6957ed2180259eb1eb7171c7563929aeb3efe23a /include/shared/linked_list.h | |
parent | d2adb901779e0069ecbd023114d5e689cebf2eba (diff) | |
download | stm32l4-c4cd1464e6f253a2d1d83ec93a16053c5a247b6f.tar.gz stm32l4-c4cd1464e6f253a2d1d83ec93a16053c5a247b6f.tar.bz2 stm32l4-c4cd1464e6f253a2d1d83ec93a16053c5a247b6f.zip |
Some changes to linked list
Diffstat (limited to 'include/shared/linked_list.h')
-rw-r--r-- | include/shared/linked_list.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/include/shared/linked_list.h b/include/shared/linked_list.h index 17c2cdd..3f8e075 100644 --- a/include/shared/linked_list.h +++ b/include/shared/linked_list.h @@ -10,17 +10,17 @@ #define linked_list_front(type) linked_list_front_##type #define linked_list_back(type) linked_list_back_##type #define linked_list_length(type) linked_list_length_##type -#define linked_list_length(type) linked_list_length_##type #define LINKED_LIST_INIT \ { \ .head = NULL \ } -#define linked_list_foreach(ll, val) \ - for (typeof(ll.head) _cur_ = ll.head, typeof(_cur_->value) val; \ - _cur_ != NULL && ((val = _cur_->value) || 1); \ - _cur_ = _cur_->next) +#define linked_list_foreach(ll, val) \ + typeof(ll.head) _cur_ = ll.head; \ + typeof(_cur_->value) val; \ + if (_cur_) val = _cur_->value; \ + for (; _cur_ != NULL; _cur_ = _cur_->next, val = _cur_ ? _cur_->value : val) #define NO_ATTRIBUTE |