From b134e7cdf0d37bf58c244dceb67209dea0a67489 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Mon, 22 Sep 2025 14:12:46 +0200 Subject: [PATCH] change refactor free option descriptor --- src/kds_s2000w_option_descriptors.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index e733df0..1aa117b 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -1218,24 +1218,20 @@ void kds_s2000w_option_descriptors_free() { kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_free_option_descriptors"); - SANE_Option_Descriptor* descriptor = NULL; - for (int i = 0; i < MAX_OPTION_COUNT; i++) { - descriptor = kds_s2000w_option_descriptors_get_by_number(i); - - if (descriptor->constraint_type == SANE_CONSTRAINT_STRING_LIST) { - free((void*) descriptor->constraint.string_list); - descriptor->constraint.string_list = NULL; + if (descriptors[i]->descriptor.constraint_type == SANE_CONSTRAINT_STRING_LIST) { + free((void*) descriptors[i]->descriptor.constraint.string_list); + descriptors[i]->descriptor.constraint.string_list = NULL; } - if (descriptor->constraint_type == SANE_CONSTRAINT_WORD_LIST) { - free((void*) descriptor->constraint.word_list); - descriptor->constraint.word_list = NULL; + if (descriptors[i]->descriptor.constraint_type == SANE_CONSTRAINT_WORD_LIST) { + free((void*) descriptors[i]->descriptor.constraint.word_list); + descriptors[i]->descriptor.constraint.word_list = NULL; } - if (descriptor->constraint_type == SANE_CONSTRAINT_RANGE) { - free((void*) descriptor->constraint.range); - descriptor->constraint.range = NULL; + if (descriptors[i]->descriptor.constraint_type == SANE_CONSTRAINT_RANGE) { + free((void*) descriptors[i]->descriptor.constraint.range); + descriptors[i]->descriptor.constraint.range = NULL; } free(descriptors[i]); -- 2.47.3