]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change free option descriptor string list
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 12:06:30 +0000 (13:06 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 12:06:30 +0000 (13:06 +0100)
src/kds_s2000w_option_descriptors.c

index 534e31a305941c9d2c894e251009fe2924c964f9..6efe236acb1f6b233fe7faa875353e136f514ab8 100644 (file)
@@ -16,27 +16,6 @@ SANE_Range constraint_color_balance_red = {-50, 50, 1};
 SANE_Range constraint_color_balance_green = {-50, 50, 1};
 SANE_Range constraint_color_balance_blue = {-50, 50, 1};
 SANE_Range constraint_foreground_boldness_aggressiveness = {-10, 10, 1};
-SANE_String_Const* constraint_scanside = NULL;
-SANE_String_Const* constraint_colormode = NULL;
-SANE_String_Const* constraint_colordrop = NULL;
-SANE_String_Const* constraint_color_auto_brightnessmode = NULL;
-SANE_String_Const* constraint_color_balance_mode = NULL;
-SANE_String_Const* constraint_foreground_boldness_mode = NULL;
-SANE_String_Const* constraint_background_smoothing_mode = NULL;
-SANE_String_Const* constraint_binarization_mode = NULL;
-SANE_String_Const* constraint_max_document_length = NULL;
-SANE_String_Const* constraint_scan_source = NULL;
-SANE_String_Const* constraint_color_sharpen = NULL;
-SANE_String_Const* constraint_multifeed_sensitivity = NULL;
-SANE_String_Const* constraint_multifeed_response = NULL;
-SANE_String_Const* constraint_post_scan_rotation = NULL;
-SANE_String_Const* constraint_edge_fill = NULL;
-SANE_String_Const* constraint_image_border = NULL;
-SANE_String_Const* constraint_transport_handling = NULL;
-SANE_String_Const* constraint_jpeg_quality = NULL;
-SANE_String_Const* constraint_document_feeder_timeout_response = NULL;
-SANE_String_Const* constraint_cropping_mode = NULL;
-SANE_String_Const* constraint_cropping_image = NULL;
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_standard_group()
 {
@@ -115,10 +94,10 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_scanside()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_scanside");
 
-       constraint_scanside = malloc(sizeof(SANE_String_Const*) * 3);
-       constraint_scanside[0] = "Simplex";
-       constraint_scanside[1] = "Duplex";
-       constraint_scanside[2] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 3);
+       constraint[0] = "Simplex";
+       constraint[1] = "Duplex";
+       constraint[2] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "scanside",
@@ -129,7 +108,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_scanside()
                sizeof(SANE_String_Const*) * 3,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_scanside}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -139,11 +118,11 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_mode()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_color_mode");
 
-       constraint_colormode = malloc(sizeof(SANE_String_Const*) * 4);
-       constraint_colormode[0] = "Color";
-       constraint_colormode[1] = "Gray";
-       constraint_colormode[2] = "BW";
-       constraint_colormode[3] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 4);
+       constraint[0] = "Color";
+       constraint[1] = "Gray";
+       constraint[2] = "BW";
+       constraint[3] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                SANE_NAME_SCAN_MODE,
@@ -154,7 +133,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_mode()
                sizeof(SANE_String_Const*) * 4,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_colormode}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -182,16 +161,16 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_drop()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_color_drop");
 
-       constraint_colordrop = malloc(sizeof(SANE_String_Const*) * 9);
-       constraint_colordrop[0] = "None";
-       constraint_colordrop[1] = "Red";
-       constraint_colordrop[2] = "Green";
-       constraint_colordrop[3] = "Blue";
-       constraint_colordrop[4] = "Orange";
-       constraint_colordrop[5] = "OrangeAndRed";
-       constraint_colordrop[6] = "Predominant";
-       constraint_colordrop[7] = "Multiple";
-       constraint_colordrop[8] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 9);
+       constraint[0] = "None";
+       constraint[1] = "Red";
+       constraint[2] = "Green";
+       constraint[3] = "Blue";
+       constraint[4] = "Orange";
+       constraint[5] = "OrangeAndRed";
+       constraint[6] = "Predominant";
+       constraint[7] = "Multiple";
+       constraint[8] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "colordrop",
@@ -202,7 +181,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_drop()
                sizeof(SANE_String_Const*) * 9,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_colordrop}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -231,11 +210,11 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_auto_brightness_mode(
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_color_auto_brightness_mode");
 
-       constraint_color_auto_brightnessmode = malloc(sizeof(SANE_String_Const*) * 4);
-       constraint_color_auto_brightnessmode[0] = "None";
-       constraint_color_auto_brightnessmode[1] = "Manual";
-       constraint_color_auto_brightnessmode[2] = "Automatic";
-       constraint_color_auto_brightnessmode[3] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 4);
+       constraint[0] = "None";
+       constraint[1] = "Manual";
+       constraint[2] = "Automatic";
+       constraint[3] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "colorautobrightnessmode",
@@ -246,7 +225,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_auto_brightness_mode(
                sizeof(SANE_String_Const*) * 4,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_color_auto_brightnessmode}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -256,12 +235,12 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_balance_mode()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_color_balance_mode");
 
-       constraint_color_balance_mode = malloc(sizeof(SANE_String_Const*) * 5);
-       constraint_color_balance_mode[0] = "None";
-       constraint_color_balance_mode[1] = "Manual";
-       constraint_color_balance_mode[2] = "Automatic";
-       constraint_color_balance_mode[3] = "AutomaticAdvanced";
-       constraint_color_balance_mode[4] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 5);
+       constraint[0] = "None";
+       constraint[1] = "Manual";
+       constraint[2] = "Automatic";
+       constraint[3] = "AutomaticAdvanced";
+       constraint[4] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "colorbalancemode",
@@ -272,7 +251,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_balance_mode()
                sizeof(SANE_String_Const*) * 5,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_color_balance_mode}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -358,11 +337,11 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_foreground_boldness_mode()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_foreground_boldness_mode");
 
-       constraint_foreground_boldness_mode = malloc(sizeof(SANE_String_Const*) * 4);
-       constraint_foreground_boldness_mode[0] = "None";
-       constraint_foreground_boldness_mode[1] = "AutomaticAdvanced";
-       constraint_foreground_boldness_mode[2] = "Automatic";
-       constraint_foreground_boldness_mode[3] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 4);
+       constraint[0] = "None";
+       constraint[1] = "AutomaticAdvanced";
+       constraint[2] = "Automatic";
+       constraint[3] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "foreground-boldness-mode",
@@ -373,7 +352,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_foreground_boldness_mode()
                sizeof(SANE_String_Const*) * 4,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_foreground_boldness_mode}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -402,11 +381,11 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_background_smoothing_mode()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_background_smoothing_mode");
 
-       constraint_background_smoothing_mode = malloc(sizeof(SANE_String_Const*) * 4);
-       constraint_background_smoothing_mode[0] = "None";
-       constraint_background_smoothing_mode[1] = "AutomaticAdvanced";
-       constraint_background_smoothing_mode[2] = "Automatic";
-       constraint_background_smoothing_mode[3] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 4);
+       constraint[0] = "None";
+       constraint[1] = "AutomaticAdvanced";
+       constraint[2] = "Automatic";
+       constraint[3] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "background-smoothing-mode",
@@ -417,7 +396,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_background_smoothing_mode()
                sizeof(SANE_String_Const*) * 4,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_background_smoothing_mode}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -465,11 +444,11 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_scan_source()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_scan_source");
 
-       constraint_scan_source = malloc(sizeof(SANE_String_Const*) * 4);
-       constraint_scan_source[0] = "DocumentFeeder";
-       constraint_scan_source[1] = "Automatic";
-       constraint_scan_source[2] = "Flatbed";
-       constraint_scan_source[3] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 4);
+       constraint[0] = "DocumentFeeder";
+       constraint[1] = "Automatic";
+       constraint[2] = "Flatbed";
+       constraint[3] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                SANE_NAME_SCAN_SOURCE,
@@ -480,7 +459,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_scan_source()
                sizeof(SANE_String_Const*) * 4,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_scan_source}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -508,12 +487,12 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_sharpen()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_color_sharpen");
 
-       constraint_color_sharpen = malloc(sizeof(SANE_String_Const*) * 5);
-       constraint_color_sharpen[0] = "None";
-       constraint_color_sharpen[1] = "Normal";
-       constraint_color_sharpen[2] = "High";
-       constraint_color_sharpen[3] = "Exaggerated";
-       constraint_color_sharpen[4] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 5);
+       constraint[0] = "None";
+       constraint[1] = "Normal";
+       constraint[2] = "High";
+       constraint[3] = "Exaggerated";
+       constraint[4] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "color-sharpen",
@@ -524,7 +503,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_sharpen()
                sizeof(SANE_String_Const*) * 5,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_color_sharpen}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -534,12 +513,12 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_multifeed_sensitivity()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_multifeed_sensitivity");
 
-       constraint_multifeed_sensitivity = malloc(sizeof(SANE_String_Const*) * 5);
-       constraint_multifeed_sensitivity[0] = "None";
-       constraint_multifeed_sensitivity[1] = "Low";
-       constraint_multifeed_sensitivity[2] = "Medium";
-       constraint_multifeed_sensitivity[3] = "High";
-       constraint_multifeed_sensitivity[4] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 5);
+       constraint[0] = "None";
+       constraint[1] = "Low";
+       constraint[2] = "Medium";
+       constraint[3] = "High";
+       constraint[4] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "multifeed-sensitivity",
@@ -550,7 +529,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_multifeed_sensitivity()
                sizeof(SANE_String_Const*) * 5,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_multifeed_sensitivity}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -560,10 +539,10 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_multifeed_response()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_multifeed_response");
 
-       constraint_multifeed_response = malloc(sizeof(SANE_String_Const*) * 5);
-       constraint_multifeed_response[0] = "Stop";
-       constraint_multifeed_response[1] = "StopAndGenerateImage";
-       constraint_multifeed_response[2] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 5);
+       constraint[0] = "Stop";
+       constraint[1] = "StopAndGenerateImage";
+       constraint[2] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "multifeed-response",
@@ -574,7 +553,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_multifeed_response()
                sizeof(SANE_String_Const*) * 3,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_multifeed_response}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -584,13 +563,13 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_post_scan_rotation()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_post_scan_rotation");
 
-       constraint_post_scan_rotation = malloc(sizeof(SANE_String_Const*) * 6);
-       constraint_post_scan_rotation[0] = "None";
-       constraint_post_scan_rotation[1] = "Automatic";
-       constraint_post_scan_rotation[2] = "Automatic90";
-       constraint_post_scan_rotation[3] = "Automatic180";
-       constraint_post_scan_rotation[4] = "Automatic270";
-       constraint_post_scan_rotation[5] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 6);
+       constraint[0] = "None";
+       constraint[1] = "Automatic";
+       constraint[2] = "Automatic90";
+       constraint[3] = "Automatic180";
+       constraint[4] = "Automatic270";
+       constraint[5] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "post-scan-rotation",
@@ -601,7 +580,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_post_scan_rotation()
                sizeof(SANE_String_Const*) * 6,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_post_scan_rotation}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -611,11 +590,11 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_edge_fill()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_edge_fill");
 
-       constraint_edge_fill = malloc(sizeof(SANE_String_Const*) * 4);
-       constraint_edge_fill[0] = "None";
-       constraint_edge_fill[1] = "Automatic";
-       constraint_edge_fill[2] = "AutomaticIncludeTears";
-       constraint_edge_fill[3] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 4);
+       constraint[0] = "None";
+       constraint[1] = "Automatic";
+       constraint[2] = "AutomaticIncludeTears";
+       constraint[3] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "edge-fill",
@@ -626,7 +605,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_edge_fill()
                sizeof(SANE_String_Const*) * 4,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_edge_fill}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -636,11 +615,11 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_image_border()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_image_border");
 
-       constraint_image_border = malloc(sizeof(SANE_String_Const*) * 4);
-       constraint_image_border[0] = "None";
-       constraint_image_border[1] = "Add";
-       constraint_image_border[2] = "Remove";
-       constraint_image_border[3] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 4);
+       constraint[0] = "None";
+       constraint[1] = "Add";
+       constraint[2] = "Remove";
+       constraint[3] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "image-border",
@@ -651,7 +630,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_image_border()
                sizeof(SANE_String_Const*) * 4,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_image_border}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -661,12 +640,12 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_transport_handling()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_transport_handling");
 
-       constraint_transport_handling = malloc(sizeof(SANE_String_Const*) * 5);
-       constraint_transport_handling[0] = "Normal";
-       constraint_transport_handling[1] = "ImprovedStacking";
-       constraint_transport_handling[2] = "BestStacking";
-       constraint_transport_handling[3] = "Special";
-       constraint_transport_handling[4] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 5);
+       constraint[0] = "Normal";
+       constraint[1] = "ImprovedStacking";
+       constraint[2] = "BestStacking";
+       constraint[3] = "Special";
+       constraint[4] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "transport-handling",
@@ -677,7 +656,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_transport_handling()
                sizeof(SANE_String_Const*) * 5,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_transport_handling}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -687,13 +666,13 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_jpeg_quality()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_jpeg_quality");
 
-       constraint_jpeg_quality = malloc(sizeof(SANE_String_Const*) * 6);
-       constraint_jpeg_quality[0] = "Draft";
-       constraint_jpeg_quality[1] = "Good";
-       constraint_jpeg_quality[2] = "Better";
-       constraint_jpeg_quality[3] = "Best";
-       constraint_jpeg_quality[4] = "Superior";
-       constraint_jpeg_quality[5] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 6);
+       constraint[0] = "Draft";
+       constraint[1] = "Good";
+       constraint[2] = "Better";
+       constraint[3] = "Best";
+       constraint[4] = "Superior";
+       constraint[5] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "jpeg-quality",
@@ -704,7 +683,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_jpeg_quality()
                sizeof(SANE_String_Const*) * 6,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_jpeg_quality}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -714,11 +693,11 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_document_feeder_timeout_res
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_document_feeder_timeout_response");
 
-       constraint_document_feeder_timeout_response = malloc(sizeof(SANE_String_Const*) * 4);
-       constraint_document_feeder_timeout_response[0] = "Stop";
-       constraint_document_feeder_timeout_response[1] = "Pause";
-       constraint_document_feeder_timeout_response[2] = "PauseAndWait";
-       constraint_document_feeder_timeout_response[3] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 4);
+       constraint[0] = "Stop";
+       constraint[1] = "Pause";
+       constraint[2] = "PauseAndWait";
+       constraint[3] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "document-feeder-timeout-response",
@@ -729,7 +708,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_document_feeder_timeout_res
                sizeof(SANE_String_Const*) * 4,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_document_feeder_timeout_response}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -758,12 +737,12 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_cropping_mode()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_cropping_mode");
 
-       constraint_cropping_mode = malloc(sizeof(SANE_String_Const*) * 5);
-       constraint_cropping_mode[0] = "AutomaticStraighten";
-       constraint_cropping_mode[1] = "Automatic";
-       constraint_cropping_mode[2] = "Photograph";
-       constraint_cropping_mode[3] = "Manual";
-       constraint_cropping_mode[4] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 5);
+       constraint[0] = "AutomaticStraighten";
+       constraint[1] = "Automatic";
+       constraint[2] = "Photograph";
+       constraint[3] = "Manual";
+       constraint[4] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "cropping-mode",
@@ -774,7 +753,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_cropping_mode()
                sizeof(SANE_String_Const*) * 5,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_cropping_mode}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -784,10 +763,10 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_cropping_image()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_cropping_image");
 
-       constraint_cropping_image = malloc(sizeof(SANE_String_Const*) * 3);
-       constraint_cropping_image[0] = "EntireDocument";
-       constraint_cropping_image[1] = "PartialDocument";
-       constraint_cropping_image[2] = NULL;
+       char** constraint = malloc(sizeof(SANE_String_Const*) * 3);
+       constraint[0] = "EntireDocument";
+       constraint[1] = "PartialDocument";
+       constraint[2] = NULL;
 
        SANE_Option_Descriptor descriptor = {
                "cropping-image",
@@ -798,7 +777,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_cropping_image()
                sizeof(SANE_String_Const*) * 3,
                SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
                SANE_CONSTRAINT_STRING_LIST,
-               {.string_list = constraint_cropping_image}
+               {.string_list = (SANE_String_Const*) constraint}
        };
 
        return descriptor;
@@ -849,48 +828,16 @@ void kds_s2000w_option_descriptors_free()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_free_option_descriptors");
 
-       free(constraint_scanside);
-       constraint_scanside = NULL;
-       free(constraint_colormode);
-       constraint_colormode = NULL;
-       free(constraint_colordrop);
-       constraint_colordrop = NULL;
-       free(constraint_color_auto_brightnessmode);
-       constraint_color_auto_brightnessmode = NULL;
-       free(constraint_color_balance_mode);
-       constraint_color_balance_mode = NULL;
-       free(constraint_foreground_boldness_mode);
-       constraint_foreground_boldness_mode = NULL;
-       free(constraint_background_smoothing_mode);
-       constraint_background_smoothing_mode = NULL;
-       free(constraint_binarization_mode);
-       constraint_binarization_mode = NULL;
-       free(constraint_max_document_length);
-       constraint_max_document_length = NULL;
-       free(constraint_scan_source);
-       constraint_scan_source = NULL;
-       free(constraint_color_sharpen);
-       constraint_color_sharpen = NULL;
-       free(constraint_multifeed_sensitivity);
-       constraint_multifeed_sensitivity = NULL;
-       free(constraint_multifeed_response);
-       constraint_multifeed_response = NULL;
-       free(constraint_post_scan_rotation);
-       constraint_post_scan_rotation = NULL;
-       free(constraint_edge_fill);
-       constraint_edge_fill = NULL;
-       free(constraint_image_border);
-       constraint_image_border = NULL;
-       free(constraint_transport_handling);
-       constraint_transport_handling = NULL;
-       free(constraint_jpeg_quality);
-       constraint_jpeg_quality = NULL;
-       free(constraint_document_feeder_timeout_response);
-       constraint_document_feeder_timeout_response = NULL;
-       free(constraint_cropping_mode);
-       constraint_cropping_mode = NULL;
-       free(constraint_cropping_image);
-       constraint_cropping_image = NULL;
+       SANE_Option_Descriptor* descriptor = NULL;
+
+       for (int i = 0; i < MAX_OPTION_COUNT; i++) {
+               descriptor = kds_s2000w_option_descriptors_get(i);
+               if (descriptor->constraint_type == SANE_CONSTRAINT_STRING_LIST) {
+                       free((void*) descriptor->constraint.string_list);
+                       descriptor->constraint.string_list = NULL;
+               }
+       }
+
        free(descriptor_array);
        descriptor_array = NULL;
 }