[PATCH 0/4] alist: Implement a pointer list / array of structs
Simon Glass
sjg at chromium.org
Tue Jun 11 20:50:47 CEST 2024
This data structure provides a list of pointers / array of structures.
I was planning to use it for the lmb restructure, to allow it to
support any number of entries, but then I gave up on it.
There are quite a few places in U-Boot where such a list would be
useful, since it supports growing the array.
The series includes a patch to convert an existing function to use
this.
It adds a little under 300 bytes of code with Thumb2.
Example:
struct my_struct obj;
struct my_struct *ptr = alist_add(&lst, &obj, struct my_struct);
// now ptr is in the list
[1] https://patchwork.ozlabs.org/project/uboot/list/?series=371258&state=*
Simon Glass (4):
malloc: Support testing with realloc()
lib: Handle a special case with str_to_list()
alist: Add support for an allocated pointer list
lib: Convert str_to_list() to use alist
common/dlmalloc.c | 4 +
include/alist.h | 205 ++++++++++++++++++++++++++++++++++++++++++++++
lib/Makefile | 1 +
lib/alist.c | 154 ++++++++++++++++++++++++++++++++++
lib/strto.c | 33 ++++----
test/lib/Makefile | 1 +
test/lib/alist.c | 197 ++++++++++++++++++++++++++++++++++++++++++++
test/str_ut.c | 4 +-
8 files changed, 582 insertions(+), 17 deletions(-)
create mode 100644 include/alist.h
create mode 100644 lib/alist.c
create mode 100644 test/lib/alist.c
--
2.34.1
More information about the U-Boot
mailing list