From fc7c89f1d4fb124e26c88ccca9350f1626adbf44 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Thu, 16 Jul 2026 22:56:46 +0200 Subject: [PATCH] Move ordering of memory sections after reading config file As suggested, sort the memory sections into order right after reading the config file, so all consumers of the library will later see them in the same order. --- src/config_gram.y | 4 ++++ src/main.c | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/config_gram.y b/src/config_gram.y index 07024000..fe9ecbbb 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -378,6 +378,10 @@ part_def : yywarning("revise fileio_mem_offset(), avrdude.conf entry or memory type assignment"); } + // Sort memories in canonical order + if(current_part->mem) + lsort(current_part->mem, avr_mem_cmp); + existing_part = locate_part(part_list, current_part->id); if(existing_part) { { /* temporarily set lineno to lineno of part start */ diff --git a/src/main.c b/src/main.c index d2a430c4..f239c129 100644 --- a/src/main.c +++ b/src/main.c @@ -1184,11 +1184,6 @@ int main(int argc, char *argv[]) { } } - // Sort memories of all parts in canonical order - for(LNODEID ln1 = lfirst(part_list); ln1; ln1 = lnext(ln1)) - if((p = ldata(ln1))->mem) - lsort(p->mem, avr_mem_cmp); - // Set bitclock from configuration files unless changed by command line if(default_bitclock > 0 && bitclock == 0.0) { bitclock = default_bitclock;