From c4cd1464e6f253a2d1d83ec93a16053c5a247b6f Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 3 Dec 2020 00:53:04 -0700 Subject: Some changes to linked list --- include/shared/linked_list.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/shared/linked_list.h') 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 -- cgit