From: Bastian Dehn Date: Tue, 30 Jul 2024 11:19:13 +0000 (+0200) Subject: change option descriptor array to heap X-Git-Tag: v1.0.4^2~12 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=9b255da9037a6bcc85e4a719ea0ac30ea3af462b;p=sane-kds-s2000w-net.git change option descriptor array to heap --- diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index 2bcfd49..6f0a864 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -3,7 +3,7 @@ #include "kds_s2000w_option_descriptors.h" #include "kds_s2000w_debug.h" -SANE_Option_Descriptor descriptor_array[MAX_OPTION_COUNT]; +SANE_Option_Descriptor* descriptor_array = NULL; SANE_Word constraint_dpi[] = {2, 200, 300}; SANE_Range constraint_binarization_contrast = {-50, 50, 1}; @@ -516,6 +516,7 @@ void kds_s2000w_option_descriptor_init_option_descriptors() { debug_printf(ALL, "kds_s2000w_option_descriptor_init_option_descriptors"); + descriptor_array = malloc(sizeof(SANE_Option_Descriptor) * MAX_OPTION_COUNT); descriptor_array[0] = _kds_s2000w_option_descriptor_num_options(); descriptor_array[1] = _kds_s2000w_option_descriptor_standard_group(); descriptor_array[2] = _kds_s2000w_option_descriptor_scan_source(); @@ -563,6 +564,8 @@ void kds_s2000w_option_descriptor_free_option_descriptors() constraint_max_document_length = NULL; free(constraint_scan_source); constraint_scan_source = NULL; + free(descriptor_array); + descriptor_array = NULL; } SANE_Option_Descriptor* kds_s2000w_option_get_descriptor(int option) diff --git a/tests/kds_s2000w_net_get_opt_tests.c b/tests/kds_s2000w_net_get_opt_tests.c index a28ae4a..2cc3599 100644 --- a/tests/kds_s2000w_net_get_opt_tests.c +++ b/tests/kds_s2000w_net_get_opt_tests.c @@ -35,7 +35,7 @@ void sane_kds_s2000w_net_control_get_option_zero(void** state) _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 23); + assert_int_equal(value, 22); free_handler(h); h = NULL;