]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add free constraints in option descriptor
authorBastian Dehn <hhaalo@arcor.de>
Tue, 20 Feb 2024 20:58:16 +0000 (21:58 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 20 Feb 2024 21:03:37 +0000 (22:03 +0100)
src/kds_s2000w_option_descriptors.c

index c1b59260d4787dd3542e18042a8277791c140c93..e1ba045d74a793e095458d8d1327818636d99905 100644 (file)
@@ -5,6 +5,31 @@
 
 SANE_Option_Descriptor** descriptor_array = NULL;
 
+SANE_Word* constraint_dpi = NULL;
+SANE_String_Const* constraint_scanside = NULL;
+SANE_String_Const* constraint_colormode = NULL;
+SANE_String_Const* constraint_colordrop = NULL;
+SANE_Range* constraint_color_drop_out_aggressiveness_range = NULL;
+SANE_String_Const* constraint_output_type = NULL;
+SANE_String_Const* constraint_color_auto_brightnessmode = NULL;
+SANE_String_Const* constraint_color_balance_mode = NULL;
+SANE_Range* constraint_color_balance_aggressiveness = NULL;
+SANE_Range* constraint_color_balance_red = NULL;
+SANE_Range* constraint_color_balance_green = NULL;
+SANE_Range* constraint_color_balance_blue = NULL;
+SANE_String_Const* constraint_foreground_boldness_mode = NULL;
+SANE_Range* constraint_foreground_boldness_aggressiveness = NULL;
+SANE_String_Const* constraint_background_smoothing_mode = NULL;
+SANE_Range* constraint_background_smoothing_aggressivness = NULL;
+SANE_String_Const* constraint_binarization_mode = NULL;
+SANE_Range* constraint_binarization_contrast = NULL;
+SANE_String_Const* constraint_max_document_length = NULL;
+SANE_String_Const* constraint_scan_source = NULL;
+SANE_Range* constraint_gamma_range = NULL;
+SANE_Range* constraint_gamma_range_r = NULL;
+SANE_Range* constraint_gamma_range_g = NULL;
+SANE_Range* constraint_gamma_range_b = NULL;
+
 SANE_Option_Descriptor* _kds_s2000w_option_descriptor_num_options()
 {
        debug_printf(ALL, "kds_s2000w_option_descriptor_num_options");
@@ -50,7 +75,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_dpi()
        descriptor->unit = SANE_UNIT_DPI;
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_WORD_LIST;
-       SANE_Word* constraint_dpi = NULL;
        constraint_dpi = malloc(sizeof(SANE_Int) * 3);
        constraint_dpi[0] = 2;
        constraint_dpi[1] = 200;
@@ -72,7 +96,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_scanside()
        descriptor->desc = "Duplex Mode";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_scanside = NULL;
        constraint_scanside = malloc(sizeof(char*) * 3);
        constraint_scanside[0] = "Simplex";
        constraint_scanside[1] = "Duplex";
@@ -95,7 +118,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_mode()
        descriptor->desc = SANE_DESC_SCAN_MODE;
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_colormode = NULL;
        constraint_colormode = malloc(sizeof(char*) * 5);
        constraint_colormode[0] = "Color";
        constraint_colormode[1] = "Gray";
@@ -152,7 +174,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_drop()
        descriptor->desc = "colordrop";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_colordrop = NULL;
        constraint_colordrop = malloc(sizeof(char*) * 9);
        constraint_colordrop[0] = "None";
        constraint_colordrop[1] = "Red";
@@ -181,7 +202,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_drop_out_aggressiven
        descriptor->desc = "colordropoutaggressiveness";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       SANE_Range* constraint_color_drop_out_aggressiveness_range = NULL;
        constraint_color_drop_out_aggressiveness_range = malloc(sizeof(SANE_Range));
        constraint_color_drop_out_aggressiveness_range->min = -10;
        constraint_color_drop_out_aggressiveness_range->max = 10;
@@ -203,7 +223,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_output_type()
        descriptor->desc = "outputtype";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_output_type = NULL;
        constraint_output_type = malloc(sizeof(char*) * 3);
        constraint_output_type[0] = "Images";
        constraint_output_type[1] = "SinglePageColorPDFPlus2TIFs";
@@ -226,7 +245,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_auto_brightness_mode
        descriptor->desc = "colorautobrightnessmode";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_color_auto_brightnessmode = NULL;
        constraint_color_auto_brightnessmode = malloc(sizeof(char*) * 3);
        constraint_color_auto_brightnessmode[0] = "None";
        constraint_color_auto_brightnessmode[1] = "Automatic";
@@ -249,7 +267,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balance_mode()
        descriptor->desc = "colorbalancemode";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_color_balance_mode = NULL;
        constraint_color_balance_mode = malloc(sizeof(char*) * 5);
        constraint_color_balance_mode[0] = "None";
        constraint_color_balance_mode[1] = "Manual";
@@ -274,7 +291,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balancea_agressivene
        descriptor->desc = "colorbalanceaggressiveness";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       SANE_Range* constraint_color_balance_aggressiveness = NULL;
        constraint_color_balance_aggressiveness = malloc(sizeof(SANE_Range));
        constraint_color_balance_aggressiveness->min = -2;
        constraint_color_balance_aggressiveness->max = 2;
@@ -286,8 +302,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balancea_agressivene
        return descriptor;
 }
 
-
-
 SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balance_red()
 {
        debug_printf(ALL, "kds_s2000w_option_descriptor_color_balance_red");
@@ -298,7 +312,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balance_red()
        descriptor->desc = "colorbalancered";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       SANE_Range* constraint_color_balance_red = NULL;
        constraint_color_balance_red = malloc(sizeof(SANE_Range));
        constraint_color_balance_red->min = -50;
        constraint_color_balance_red->max = 50;
@@ -320,7 +333,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balance_green()
        descriptor->desc = "colorbalancegreen";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       SANE_Range* constraint_color_balance_green = NULL;
        constraint_color_balance_green = malloc(sizeof(SANE_Range));
        constraint_color_balance_green->min = -50;
        constraint_color_balance_green->max = 50;
@@ -342,7 +354,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_color_balance_blue()
        descriptor->desc = "colorbalanceblue";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       SANE_Range* constraint_color_balance_blue = NULL;
        constraint_color_balance_blue = malloc(sizeof(SANE_Range));
        constraint_color_balance_blue->min = -50;
        constraint_color_balance_blue->max = 50;
@@ -364,7 +375,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_foreground_boldness_mode()
        descriptor->desc = "Foreground Boldness Mode";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_foreground_boldness_mode = NULL;
        constraint_foreground_boldness_mode = malloc(sizeof(char*) * 4);
        constraint_foreground_boldness_mode[0] = "None";
        constraint_foreground_boldness_mode[1] = "AutomaticAdvanced";
@@ -388,7 +398,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_foreground_boldness_aggres
        descriptor->desc = "Foreground Boldness Mode";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       SANE_Range* constraint_foreground_boldness_aggressiveness = NULL;
        constraint_foreground_boldness_aggressiveness = malloc(sizeof(SANE_Range));
        constraint_foreground_boldness_aggressiveness->min = -10;
        constraint_foreground_boldness_aggressiveness->max = 10;
@@ -410,7 +419,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_background_smoothing_mode(
        descriptor->desc = "Background Smoothing Mode";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_background_smoothing_mode = NULL;
        constraint_background_smoothing_mode = malloc(sizeof(char*) * 4);
        constraint_background_smoothing_mode[0] = "None";
        constraint_background_smoothing_mode[1] = "AutomaticAdvanced";
@@ -434,7 +442,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_background_smoothing_aggre
        descriptor->desc = "Background Smoothing Aggressivenes";
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       SANE_Range* constraint_background_smoothing_aggressivness = NULL;
        constraint_background_smoothing_aggressivness = malloc(sizeof(SANE_Range));
        constraint_background_smoothing_aggressivness->min = -10;
        constraint_background_smoothing_aggressivness->max = 10;
@@ -456,7 +463,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_binarization_mode()
        descriptor->desc = "binarizationmode";
        descriptor->cap = SANE_CAP_SOFT_DETECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_binarization_mode = NULL;
        constraint_binarization_mode = malloc(sizeof(char*) * 2);
        constraint_binarization_mode[0] = "iThresholding";
        constraint_binarization_mode[1] = NULL;
@@ -478,7 +484,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_binarization_contrast()
        descriptor->desc = SANE_DESC_CONTRAST;
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       SANE_Range* constraint_binarization_contrast = NULL;
        constraint_binarization_contrast = malloc(sizeof(SANE_Range));
        constraint_binarization_contrast->min = -50;
        constraint_binarization_contrast->max = 50;
@@ -500,7 +505,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_max_document_length()
        descriptor->desc = "maxdocumentlength";
        descriptor->cap = SANE_CAP_SOFT_DETECT;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_max_document_length = NULL;
        constraint_max_document_length = malloc(sizeof(char*) * 2);
        constraint_max_document_length[0] = "#NoPrimaryControl#";
        constraint_max_document_length[1] = NULL;
@@ -521,7 +525,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_scan_source()
        descriptor->desc = SANE_DESC_SCAN_SOURCE;
        descriptor->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;;
        descriptor->constraint_type = SANE_CONSTRAINT_STRING_LIST;
-       SANE_String_Const* constraint_scan_source = NULL;
        constraint_scan_source = malloc(sizeof(char*) * 4);
        constraint_scan_source[0] = "DocumentFeeder";
        constraint_scan_source[1] = "Automatic";
@@ -562,7 +565,6 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_gamma_vector()
        descriptor->desc = SANE_DESC_GAMMA_VECTOR;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
-       SANE_Range* constraint_gamma_range = NULL;
        constraint_gamma_range = malloc(sizeof(SANE_Range));
        constraint_gamma_range->min = 0;
        constraint_gamma_range->max = 255;
@@ -583,14 +585,13 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_gamma_vector_r()
        descriptor->desc = SANE_DESC_GAMMA_VECTOR_R;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
-       SANE_Range* constraint_gamma_range = NULL;
-       constraint_gamma_range = malloc(sizeof(SANE_Range));
+       constraint_gamma_range_r = malloc(sizeof(SANE_Range));
        constraint_gamma_range->min = 0;
        constraint_gamma_range->max = 255;
        constraint_gamma_range->quant = 1;
        descriptor->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       descriptor->constraint.range = constraint_gamma_range;
+       descriptor->constraint.range = constraint_gamma_range_r;
        descriptor->size = sizeof(SANE_Int) * 256;
 }
 
@@ -604,19 +605,16 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_gamma_vector_g()
        descriptor->desc = SANE_DESC_GAMMA_VECTOR_G;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
-       SANE_Range* constraint_gamma_range = NULL;
-       constraint_gamma_range = malloc(sizeof(SANE_Range));
+       constraint_gamma_range_g = malloc(sizeof(SANE_Range));
        constraint_gamma_range->min = 0;
        constraint_gamma_range->max = 255;
        constraint_gamma_range->quant = 0;
        descriptor->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       descriptor->constraint.range = constraint_gamma_range;
+       descriptor->constraint.range = constraint_gamma_range_g;
        descriptor->size = sizeof(SANE_Int) * 256;
 }
 
-
-
 SANE_Option_Descriptor* _kds_s2000w_option_descriptor_gamma_vector_b()
 {
        debug_printf(ALL, "kds_s2000w_option_descriptor_gamma_vector_b");
@@ -627,14 +625,13 @@ SANE_Option_Descriptor* _kds_s2000w_option_descriptor_gamma_vector_b()
        descriptor->desc = SANE_DESC_GAMMA_VECTOR_B;
        descriptor->type = SANE_TYPE_INT;
        descriptor->unit = SANE_UNIT_NONE;
-       SANE_Range* constraint_gamma_range = NULL;
-       constraint_gamma_range = malloc(sizeof(SANE_Range));
+       constraint_gamma_range_b = malloc(sizeof(SANE_Range));
        constraint_gamma_range->min = 0;
        constraint_gamma_range->max = 255;
        constraint_gamma_range->quant = 0;
        descriptor->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE;
        descriptor->constraint_type = SANE_CONSTRAINT_RANGE;
-       descriptor->constraint.range = constraint_gamma_range;
+       descriptor->constraint.range = constraint_gamma_range_b;
        descriptor->size = sizeof(SANE_Int) * 256;
 }
 
@@ -677,8 +674,58 @@ void kds_s2000w_option_descriptor_init_option_descriptors()
 void kds_s2000w_option_descriptor_free_option_descriptors()
 {
        debug_printf(ALL, "kds_s2000w_option_descriptor_free_option_descriptors");
+       free(constraint_dpi);
+       constraint_dpi = NULL;
+       free(constraint_scanside);
+       constraint_scanside = NULL;
+       free(constraint_colormode);
+       constraint_colormode = NULL;
+       free(constraint_colordrop);
+       constraint_colordrop = NULL;
+       free(constraint_color_drop_out_aggressiveness_range);
+       constraint_color_drop_out_aggressiveness_range = NULL;
+       free(constraint_output_type);
+       constraint_output_type = NULL;
+       free(constraint_color_auto_brightnessmode);
+       constraint_color_auto_brightnessmode = NULL;
+       free(constraint_color_balance_mode);
+       constraint_color_balance_mode = NULL;
+       free(constraint_color_balance_aggressiveness);
+       constraint_color_balance_aggressiveness = NULL;
+       free(constraint_color_balance_red);
+       constraint_color_balance_red = NULL;
+       free(constraint_color_balance_green);
+       constraint_color_balance_green = NULL;
+       free(constraint_color_balance_blue);
+       constraint_color_balance_blue = NULL;
+       free(constraint_foreground_boldness_mode);
+       constraint_foreground_boldness_mode = NULL;
+       free(constraint_foreground_boldness_aggressiveness);
+       constraint_foreground_boldness_aggressiveness = NULL;
+       free(constraint_background_smoothing_mode);
+       constraint_background_smoothing_mode = NULL;
+       free(constraint_background_smoothing_aggressivness);
+       constraint_background_smoothing_aggressivness = NULL;
+       free(constraint_binarization_mode);
+       constraint_binarization_mode = NULL;
+       free(constraint_binarization_contrast);
+       constraint_binarization_contrast = NULL;
+       free(constraint_max_document_length);
+       constraint_max_document_length = NULL;
+       free(constraint_scan_source);
+       constraint_scan_source = NULL;
+       free(constraint_gamma_range);
+       constraint_gamma_range = NULL;
+       free(constraint_gamma_range_r);
+       constraint_gamma_range_r = NULL;
+       free(constraint_gamma_range_g);
+       constraint_gamma_range_g = NULL;
+       free(constraint_gamma_range_b);
+       constraint_gamma_range_b =NULL;
+
        for (int i = 0; i < MAX_OPTION_COUNT; i++) {
                free(descriptor_array[i]);
+               descriptor_array[i] = NULL;
        }
 
        free(descriptor_array);