diff options
| author | Peter Jones <pjones@redhat.com> | 2021-02-23 13:23:55 -0500 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2021-02-25 10:15:14 -0500 |
| commit | 82ce86a4bdd17581bcb42dd78245b5d961bf99bb (patch) | |
| tree | 627be322d7f8e7c2bae540e8df8048850a328c14 /include | |
| parent | c7bb10cf154aa2b84fd0c11f24caa5068aba5834 (diff) | |
| download | efi-boot-shim-82ce86a4bdd17581bcb42dd78245b5d961bf99bb.tar.gz efi-boot-shim-82ce86a4bdd17581bcb42dd78245b5d961bf99bb.zip | |
Add a list_size() primitive
This adds list_size(), which tells us how many elements are in a list.
Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/list.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/list.h b/include/list.h index ad87b45b..1d36e163 100644 --- a/include/list.h +++ b/include/list.h @@ -102,5 +102,16 @@ list_del(struct list_head *entry) for (pos = (head)->prev, n = pos->prev; pos != (head); \ pos = n, n = pos->prev) +static inline size_t +list_size(struct list_head *entry) +{ + list_t *pos; + size_t i = 0; + list_for_each(pos, entry) { + i++; + } + return i; +} + #endif /* !LIST_H_ */ // vim:fenc=utf-8:tw=75:noet |
