]> sigrok.org Git - libsigrok.git/blobdiff - src/output/output.c
output: Fix output option enumeration.
[libsigrok.git] / src / output / output.c
index 0dd1fe27f7e1cf6bf19f5674cae2546526a82906..787d75c749b4c69f5bd35f4f2b658929bf003cab 100644 (file)
@@ -187,25 +187,25 @@ SR_API const struct sr_option **sr_output_options_get(const struct sr_output_mod
  *
  * @since 0.4.0
  */
-SR_API void sr_output_options_free(const struct sr_option **opts)
+SR_API void sr_output_options_free(const struct sr_option **options)
 {
-       struct sr_option *opt;
+       int i;
 
-       if (!opts)
+       if (!options)
                return;
 
-       for (opt = (struct sr_option *)opts[0]; opt; opt++) {
-               if (opt->def) {
-                       g_variant_unref(opt->def);
-                       opt->def = NULL;
+       for (i = 0; options[i]; i++) {
+               if (options[i]->def) {
+                       g_variant_unref(options[i]->def);
+                       ((struct sr_option *)options[i])->def = NULL;
                }
 
-               if (opt->values) {
-                       g_slist_free_full(opt->values, (GDestroyNotify)g_variant_unref);
-                       opt->values = NULL;
+               if (options[i]->values) {
+                       g_slist_free_full(options[i]->values, (GDestroyNotify)g_variant_unref);
+                       ((struct sr_option *)options[i])->values = NULL;
                }
        }
-       g_free(opts);
+       g_free(options);
 }
 
 /**
@@ -225,7 +225,7 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *o,
                GHashTable *options, const struct sr_dev_inst *sdi)
 {
        struct sr_output *op;
-       struct sr_option *mod_opts;
+       const struct sr_option *mod_opts;
        const GVariantType *gvt;
        GHashTable *new_opts;
        GHashTableIter iter;