mod_opts = imod->options();
- for (size = 1; mod_opts[size].id; size++)
+ for (size = 0; mod_opts[size].id; size++)
;
- opts = g_malloc(size * sizeof(struct sr_option *));
+ opts = g_malloc((size + 1) * sizeof(struct sr_option *));
for (i = 0; i < size; i++)
opts[i] = &mod_opts[i];
*/
SR_API void sr_input_options_free(const struct sr_option **options)
{
- struct sr_option *opt;
+ int i;
if (!options)
return;
- for (opt = (struct sr_option *)options[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(options);
}
if (in->module->init && in->module->init(in, new_opts) != SR_OK) {
- g_hash_table_destroy(new_opts);
g_free(in);
in = NULL;
}
if (new_opts)
g_hash_table_destroy(new_opts);
+ in->buf = g_string_sized_new(128);
return in;
}
/* Found a matching module. */
in = sr_input_new(imod, NULL);
- in->buf = g_string_new_len(buf->str, buf->len);
+ g_string_insert_len(in->buf, 0, buf->str, buf->len);
break;
}
/* Found a matching module. */
in = sr_input_new(imod, NULL);
- in->buf = g_string_new_len(buf->str, buf->len);
+ g_string_insert_len(in->buf, 0, buf->str, buf->len);
break;
}
if (!in && buf)