alist: Add a function to empty the list

Sometimes it is useful to empty the list without de-allocating any of
the memory used, e.g. when the list will be re-populated immediately
afterwards.

Add a new function for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2024-10-19 09:21:46 -06:00 committed by Tom Rini
parent d785a77d18
commit 5bd4ead8bd
3 changed files with 54 additions and 0 deletions

View file

@ -274,6 +274,13 @@ bool alist_chk_ptr(const struct alist *lst, const void *ptr);
_pos < alist_end(_lst, typeof(*(_pos))); \
_pos++)
/**
* alist_empty() - Empty an alist
*
* This removes all entries from the list, without changing the allocated size
*/
void alist_empty(struct alist *lst);
/**
* alist_init() - Set up a new object list
*