Attention is currently required from: Nico Huber, Edward O'Callaghan, Daniel Campello, Anastasia Klimchuk. Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/33521 )
Change subject: layout: Use linked list for `struct romentry` ......................................................................
Patch Set 8:
(3 comments)
File layout.c:
https://review.coreboot.org/c/flashrom/+/33521/comment/688a6790_df0f841c PS8, Line 388: *layout = malloc(sizeof(**layout)); Given that you memset() the allocated space afterwards, use calloc() instead?
https://review.coreboot.org/c/flashrom/+/33521/comment/903fcdc0_b1e25a90 PS8, Line 418: entry->next = layout->head;
I missed the fact that in the beginning when layout has no entries, layout->head is null (or maybe undefined).
It's null, flashrom_layout_new() zero-initialises the newly-allocated `struct layout`. The null pointer signals the end of the linked list.
https://review.coreboot.org/c/flashrom/+/33521/comment/99b9de11_72f8a74f PS8, Line 458: if (layout == global_layout) : return; : : while (layout && layout->head) { : struct romentry *const entry = layout->head; : layout->head = entry->next; : free(entry->file); : free(entry->name); : free(entry); : } : free(layout); Given that `layout` is not modified in the while loop, how about evaluating it once?
if (!layout || layout == global_layout) return;
while (layout->head) { struct romentry *const entry = layout->head; layout->head = entry->next; free(entry->file); free(entry->name); free(entry); } free(layout);