]> git.dujemihanovic.xyz Git - u-boot.git/commit
alist: Add support for an allocated pointer list
authorSimon Glass <sjg@chromium.org>
Tue, 30 Jul 2024 14:39:37 +0000 (08:39 -0600)
committerTom Rini <trini@konsulko.com>
Wed, 7 Aug 2024 14:49:10 +0000 (08:49 -0600)
commit75581e419aa2bf5cc1b4c3ec79701017b44d1a66
tree3cb0c8ebdc4e2a4b00a22301b0fbddef47e0e186
parent947aafdebc9f64f12e8aa6ae7f60758f04bd1540
alist: Add support for an allocated pointer list

In various places it is useful to have an array of structures, but allow
it to grow. In some cases we work around it by setting maximum number of
entries, using a Kconfig option. In other places we use a linked list,
which does not provide for random access and can complicate the code.

Introduce a new data structure, which is a variable-sized list of structs
each of the same, pre-set size. It provides O(1) access and is reasonably
efficient at expanding linearly, since it doubles in size when it runs out
of space.

Signed-off-by: Simon Glass <sjg@chromium.org>
include/alist.h [new file with mode: 0644]
lib/Makefile
lib/alist.c [new file with mode: 0644]
test/lib/Makefile
test/lib/alist.c [new file with mode: 0644]