]>
Commit | Line | Data |
---|---|---|
eb7ee2cb LE |
1 | /* |
2 | * Options Visitor | |
3 | * | |
08f9541d | 4 | * Copyright Red Hat, Inc. 2012-2016 |
eb7ee2cb LE |
5 | * |
6 | * Author: Laszlo Ersek <[email protected]> | |
7 | * | |
8 | * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. | |
9 | * See the COPYING.LIB file in the top-level directory. | |
10 | * | |
11 | */ | |
12 | ||
cbf21151 | 13 | #include "qemu/osdep.h" |
79ee7df8 | 14 | #include "qemu-common.h" |
7b1b5d19 PB |
15 | #include "qapi/qmp/qerror.h" |
16 | #include "qapi/opts-visitor.h" | |
1de7afc9 PB |
17 | #include "qemu/queue.h" |
18 | #include "qemu/option_int.h" | |
7b1b5d19 | 19 | #include "qapi/visitor-impl.h" |
eb7ee2cb LE |
20 | |
21 | ||
d9570434 LE |
22 | enum ListMode |
23 | { | |
24 | LM_NONE, /* not traversing a list of repeated options */ | |
25 | LM_STARTED, /* opts_start_list() succeeded */ | |
d8754f40 LE |
26 | |
27 | LM_IN_PROGRESS, /* opts_next_list() has been called. | |
28 | * | |
29 | * Generating the next list link will consume the most | |
30 | * recently parsed QemuOpt instance of the repeated | |
31 | * option. | |
32 | * | |
33 | * Parsing a value into the list link will examine the | |
34 | * next QemuOpt instance of the repeated option, and | |
35 | * possibly enter LM_SIGNED_INTERVAL or | |
36 | * LM_UNSIGNED_INTERVAL. | |
37 | */ | |
38 | ||
39 | LM_SIGNED_INTERVAL, /* opts_next_list() has been called. | |
40 | * | |
41 | * Generating the next list link will consume the most | |
42 | * recently stored element from the signed interval, | |
43 | * parsed from the most recent QemuOpt instance of the | |
44 | * repeated option. This may consume QemuOpt itself | |
45 | * and return to LM_IN_PROGRESS. | |
46 | * | |
47 | * Parsing a value into the list link will store the | |
48 | * next element of the signed interval. | |
49 | */ | |
50 | ||
51 | LM_UNSIGNED_INTERVAL /* Same as above, only for an unsigned interval. */ | |
d9570434 LE |
52 | }; |
53 | ||
54 | typedef enum ListMode ListMode; | |
55 | ||
eb7ee2cb LE |
56 | struct OptsVisitor |
57 | { | |
58 | Visitor visitor; | |
59 | ||
60 | /* Ownership remains with opts_visitor_new()'s caller. */ | |
61 | const QemuOpts *opts_root; | |
62 | ||
63 | unsigned depth; | |
64 | ||
65 | /* Non-null iff depth is positive. Each key is a QemuOpt name. Each value | |
66 | * is a non-empty GQueue, enumerating all QemuOpt occurrences with that | |
67 | * name. */ | |
68 | GHashTable *unprocessed_opts; | |
69 | ||
70 | /* The list currently being traversed with opts_start_list() / | |
71 | * opts_next_list(). The list must have a struct element type in the | |
72 | * schema, with a single mandatory scalar member. */ | |
d9570434 | 73 | ListMode list_mode; |
eb7ee2cb | 74 | GQueue *repeated_opts; |
eb7ee2cb | 75 | |
d8754f40 LE |
76 | /* When parsing a list of repeating options as integers, values of the form |
77 | * "a-b", representing a closed interval, are allowed. Elements in the | |
78 | * range are generated individually. | |
79 | */ | |
80 | union { | |
81 | int64_t s; | |
82 | uint64_t u; | |
83 | } range_next, range_limit; | |
84 | ||
eb7ee2cb LE |
85 | /* If "opts_root->id" is set, reinstantiate it as a fake QemuOpt for |
86 | * uniformity. Only its "name" and "str" fields are set. "fake_id_opt" does | |
87 | * not survive or escape the OptsVisitor object. | |
88 | */ | |
89 | QemuOpt *fake_id_opt; | |
90 | }; | |
91 | ||
92 | ||
d7bea75d EB |
93 | static OptsVisitor *to_ov(Visitor *v) |
94 | { | |
95 | return container_of(v, OptsVisitor, visitor); | |
96 | } | |
97 | ||
98 | ||
eb7ee2cb LE |
99 | static void |
100 | destroy_list(gpointer list) | |
101 | { | |
102 | g_queue_free(list); | |
103 | } | |
104 | ||
105 | ||
106 | static void | |
107 | opts_visitor_insert(GHashTable *unprocessed_opts, const QemuOpt *opt) | |
108 | { | |
109 | GQueue *list; | |
110 | ||
111 | list = g_hash_table_lookup(unprocessed_opts, opt->name); | |
112 | if (list == NULL) { | |
113 | list = g_queue_new(); | |
114 | ||
115 | /* GHashTable will never try to free the keys -- we supply NULL as | |
116 | * "key_destroy_func" in opts_start_struct(). Thus cast away key | |
117 | * const-ness in order to suppress gcc's warning. | |
118 | */ | |
119 | g_hash_table_insert(unprocessed_opts, (gpointer)opt->name, list); | |
120 | } | |
121 | ||
122 | /* Similarly, destroy_list() doesn't call g_queue_free_full(). */ | |
123 | g_queue_push_tail(list, (gpointer)opt); | |
124 | } | |
125 | ||
126 | ||
127 | static void | |
337283df | 128 | opts_start_struct(Visitor *v, const char *name, void **obj, |
0b2a0d6b | 129 | size_t size, Error **errp) |
eb7ee2cb | 130 | { |
d7bea75d | 131 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
132 | const QemuOpt *opt; |
133 | ||
b7745397 MA |
134 | if (obj) { |
135 | *obj = g_malloc0(size > 0 ? size : 1); | |
136 | } | |
eb7ee2cb LE |
137 | if (ov->depth++ > 0) { |
138 | return; | |
139 | } | |
140 | ||
141 | ov->unprocessed_opts = g_hash_table_new_full(&g_str_hash, &g_str_equal, | |
142 | NULL, &destroy_list); | |
143 | QTAILQ_FOREACH(opt, &ov->opts_root->head, next) { | |
144 | /* ensured by qemu-option.c::opts_do_parse() */ | |
145 | assert(strcmp(opt->name, "id") != 0); | |
146 | ||
147 | opts_visitor_insert(ov->unprocessed_opts, opt); | |
148 | } | |
149 | ||
150 | if (ov->opts_root->id != NULL) { | |
151 | ov->fake_id_opt = g_malloc0(sizeof *ov->fake_id_opt); | |
152 | ||
dc8622f2 CL |
153 | ov->fake_id_opt->name = g_strdup("id"); |
154 | ov->fake_id_opt->str = g_strdup(ov->opts_root->id); | |
eb7ee2cb LE |
155 | opts_visitor_insert(ov->unprocessed_opts, ov->fake_id_opt); |
156 | } | |
157 | } | |
158 | ||
159 | ||
160 | static gboolean | |
161 | ghr_true(gpointer ign_key, gpointer ign_value, gpointer ign_user_data) | |
162 | { | |
163 | return TRUE; | |
164 | } | |
165 | ||
166 | ||
167 | static void | |
168 | opts_end_struct(Visitor *v, Error **errp) | |
169 | { | |
d7bea75d | 170 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
171 | GQueue *any; |
172 | ||
173 | if (--ov->depth > 0) { | |
174 | return; | |
175 | } | |
176 | ||
177 | /* we should have processed all (distinct) QemuOpt instances */ | |
178 | any = g_hash_table_find(ov->unprocessed_opts, &ghr_true, NULL); | |
179 | if (any) { | |
180 | const QemuOpt *first; | |
181 | ||
182 | first = g_queue_peek_head(any); | |
c6bd8c70 | 183 | error_setg(errp, QERR_INVALID_PARAMETER, first->name); |
eb7ee2cb LE |
184 | } |
185 | g_hash_table_destroy(ov->unprocessed_opts); | |
186 | ov->unprocessed_opts = NULL; | |
dc8622f2 CL |
187 | if (ov->fake_id_opt) { |
188 | g_free(ov->fake_id_opt->name); | |
189 | g_free(ov->fake_id_opt->str); | |
190 | g_free(ov->fake_id_opt); | |
191 | } | |
eb7ee2cb LE |
192 | ov->fake_id_opt = NULL; |
193 | } | |
194 | ||
195 | ||
196 | static GQueue * | |
197 | lookup_distinct(const OptsVisitor *ov, const char *name, Error **errp) | |
198 | { | |
199 | GQueue *list; | |
200 | ||
201 | list = g_hash_table_lookup(ov->unprocessed_opts, name); | |
202 | if (!list) { | |
c6bd8c70 | 203 | error_setg(errp, QERR_MISSING_PARAMETER, name); |
eb7ee2cb LE |
204 | } |
205 | return list; | |
206 | } | |
207 | ||
208 | ||
209 | static void | |
210 | opts_start_list(Visitor *v, const char *name, Error **errp) | |
211 | { | |
d7bea75d | 212 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
213 | |
214 | /* we can't traverse a list in a list */ | |
d9570434 | 215 | assert(ov->list_mode == LM_NONE); |
eb7ee2cb | 216 | ov->repeated_opts = lookup_distinct(ov, name, errp); |
d9570434 LE |
217 | if (ov->repeated_opts != NULL) { |
218 | ov->list_mode = LM_STARTED; | |
219 | } | |
eb7ee2cb LE |
220 | } |
221 | ||
222 | ||
223 | static GenericList * | |
08f9541d | 224 | opts_next_list(Visitor *v, GenericList **list) |
eb7ee2cb | 225 | { |
d7bea75d | 226 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
227 | GenericList **link; |
228 | ||
d9570434 LE |
229 | switch (ov->list_mode) { |
230 | case LM_STARTED: | |
231 | ov->list_mode = LM_IN_PROGRESS; | |
eb7ee2cb | 232 | link = list; |
d9570434 LE |
233 | break; |
234 | ||
d8754f40 LE |
235 | case LM_SIGNED_INTERVAL: |
236 | case LM_UNSIGNED_INTERVAL: | |
237 | link = &(*list)->next; | |
238 | ||
239 | if (ov->list_mode == LM_SIGNED_INTERVAL) { | |
240 | if (ov->range_next.s < ov->range_limit.s) { | |
241 | ++ov->range_next.s; | |
242 | break; | |
243 | } | |
244 | } else if (ov->range_next.u < ov->range_limit.u) { | |
245 | ++ov->range_next.u; | |
246 | break; | |
247 | } | |
248 | ov->list_mode = LM_IN_PROGRESS; | |
249 | /* range has been completed, fall through in order to pop option */ | |
250 | ||
d9570434 | 251 | case LM_IN_PROGRESS: { |
eb7ee2cb LE |
252 | const QemuOpt *opt; |
253 | ||
254 | opt = g_queue_pop_head(ov->repeated_opts); | |
255 | if (g_queue_is_empty(ov->repeated_opts)) { | |
256 | g_hash_table_remove(ov->unprocessed_opts, opt->name); | |
257 | return NULL; | |
258 | } | |
259 | link = &(*list)->next; | |
d9570434 LE |
260 | break; |
261 | } | |
262 | ||
263 | default: | |
264 | abort(); | |
eb7ee2cb LE |
265 | } |
266 | ||
267 | *link = g_malloc0(sizeof **link); | |
268 | return *link; | |
269 | } | |
270 | ||
271 | ||
272 | static void | |
08f9541d | 273 | opts_end_list(Visitor *v) |
eb7ee2cb | 274 | { |
d7bea75d | 275 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb | 276 | |
d8754f40 LE |
277 | assert(ov->list_mode == LM_STARTED || |
278 | ov->list_mode == LM_IN_PROGRESS || | |
279 | ov->list_mode == LM_SIGNED_INTERVAL || | |
280 | ov->list_mode == LM_UNSIGNED_INTERVAL); | |
eb7ee2cb | 281 | ov->repeated_opts = NULL; |
d9570434 | 282 | ov->list_mode = LM_NONE; |
eb7ee2cb LE |
283 | } |
284 | ||
285 | ||
286 | static const QemuOpt * | |
287 | lookup_scalar(const OptsVisitor *ov, const char *name, Error **errp) | |
288 | { | |
d9570434 | 289 | if (ov->list_mode == LM_NONE) { |
eb7ee2cb LE |
290 | GQueue *list; |
291 | ||
292 | /* the last occurrence of any QemuOpt takes effect when queried by name | |
293 | */ | |
294 | list = lookup_distinct(ov, name, errp); | |
295 | return list ? g_queue_peek_tail(list) : NULL; | |
296 | } | |
d9570434 | 297 | assert(ov->list_mode == LM_IN_PROGRESS); |
eb7ee2cb LE |
298 | return g_queue_peek_head(ov->repeated_opts); |
299 | } | |
300 | ||
301 | ||
302 | static void | |
303 | processed(OptsVisitor *ov, const char *name) | |
304 | { | |
d9570434 | 305 | if (ov->list_mode == LM_NONE) { |
eb7ee2cb | 306 | g_hash_table_remove(ov->unprocessed_opts, name); |
d9570434 | 307 | return; |
eb7ee2cb | 308 | } |
d9570434 LE |
309 | assert(ov->list_mode == LM_IN_PROGRESS); |
310 | /* do nothing */ | |
eb7ee2cb LE |
311 | } |
312 | ||
313 | ||
314 | static void | |
0b2a0d6b | 315 | opts_type_str(Visitor *v, const char *name, char **obj, Error **errp) |
eb7ee2cb | 316 | { |
d7bea75d | 317 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
318 | const QemuOpt *opt; |
319 | ||
320 | opt = lookup_scalar(ov, name, errp); | |
321 | if (!opt) { | |
322 | return; | |
323 | } | |
324 | *obj = g_strdup(opt->str ? opt->str : ""); | |
325 | processed(ov, name); | |
326 | } | |
327 | ||
328 | ||
329 | /* mimics qemu-option.c::parse_option_bool() */ | |
330 | static void | |
0b2a0d6b | 331 | opts_type_bool(Visitor *v, const char *name, bool *obj, Error **errp) |
eb7ee2cb | 332 | { |
d7bea75d | 333 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
334 | const QemuOpt *opt; |
335 | ||
336 | opt = lookup_scalar(ov, name, errp); | |
337 | if (!opt) { | |
338 | return; | |
339 | } | |
340 | ||
341 | if (opt->str) { | |
342 | if (strcmp(opt->str, "on") == 0 || | |
343 | strcmp(opt->str, "yes") == 0 || | |
344 | strcmp(opt->str, "y") == 0) { | |
345 | *obj = true; | |
346 | } else if (strcmp(opt->str, "off") == 0 || | |
347 | strcmp(opt->str, "no") == 0 || | |
348 | strcmp(opt->str, "n") == 0) { | |
349 | *obj = false; | |
350 | } else { | |
c6bd8c70 MA |
351 | error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name, |
352 | "on|yes|y|off|no|n"); | |
eb7ee2cb LE |
353 | return; |
354 | } | |
355 | } else { | |
356 | *obj = true; | |
357 | } | |
358 | ||
359 | processed(ov, name); | |
360 | } | |
361 | ||
362 | ||
363 | static void | |
0b2a0d6b | 364 | opts_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp) |
eb7ee2cb | 365 | { |
d7bea75d | 366 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
367 | const QemuOpt *opt; |
368 | const char *str; | |
369 | long long val; | |
370 | char *endptr; | |
371 | ||
d8754f40 LE |
372 | if (ov->list_mode == LM_SIGNED_INTERVAL) { |
373 | *obj = ov->range_next.s; | |
374 | return; | |
375 | } | |
376 | ||
eb7ee2cb LE |
377 | opt = lookup_scalar(ov, name, errp); |
378 | if (!opt) { | |
379 | return; | |
380 | } | |
381 | str = opt->str ? opt->str : ""; | |
382 | ||
1e1c555a LE |
383 | /* we've gotten past lookup_scalar() */ |
384 | assert(ov->list_mode == LM_NONE || ov->list_mode == LM_IN_PROGRESS); | |
385 | ||
eb7ee2cb LE |
386 | errno = 0; |
387 | val = strtoll(str, &endptr, 0); | |
1e1c555a LE |
388 | if (errno == 0 && endptr > str && INT64_MIN <= val && val <= INT64_MAX) { |
389 | if (*endptr == '\0') { | |
390 | *obj = val; | |
391 | processed(ov, name); | |
392 | return; | |
393 | } | |
394 | if (*endptr == '-' && ov->list_mode == LM_IN_PROGRESS) { | |
395 | long long val2; | |
396 | ||
397 | str = endptr + 1; | |
398 | val2 = strtoll(str, &endptr, 0); | |
399 | if (errno == 0 && endptr > str && *endptr == '\0' && | |
15a849be LE |
400 | INT64_MIN <= val2 && val2 <= INT64_MAX && val <= val2 && |
401 | (val > INT64_MAX - OPTS_VISITOR_RANGE_MAX || | |
402 | val2 < val + OPTS_VISITOR_RANGE_MAX)) { | |
1e1c555a LE |
403 | ov->range_next.s = val; |
404 | ov->range_limit.s = val2; | |
405 | ov->list_mode = LM_SIGNED_INTERVAL; | |
406 | ||
407 | /* as if entering on the top */ | |
408 | *obj = ov->range_next.s; | |
409 | return; | |
410 | } | |
411 | } | |
eb7ee2cb | 412 | } |
c6bd8c70 MA |
413 | error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name, |
414 | (ov->list_mode == LM_NONE) ? "an int64 value" : | |
415 | "an int64 value or range"); | |
eb7ee2cb LE |
416 | } |
417 | ||
418 | ||
419 | static void | |
0b2a0d6b | 420 | opts_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp) |
eb7ee2cb | 421 | { |
d7bea75d | 422 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
423 | const QemuOpt *opt; |
424 | const char *str; | |
62d090e2 | 425 | unsigned long long val; |
581a8a80 | 426 | char *endptr; |
eb7ee2cb | 427 | |
d8754f40 LE |
428 | if (ov->list_mode == LM_UNSIGNED_INTERVAL) { |
429 | *obj = ov->range_next.u; | |
430 | return; | |
431 | } | |
432 | ||
eb7ee2cb LE |
433 | opt = lookup_scalar(ov, name, errp); |
434 | if (!opt) { | |
435 | return; | |
436 | } | |
eb7ee2cb | 437 | str = opt->str; |
eb7ee2cb | 438 | |
581a8a80 LE |
439 | /* we've gotten past lookup_scalar() */ |
440 | assert(ov->list_mode == LM_NONE || ov->list_mode == LM_IN_PROGRESS); | |
441 | ||
442 | if (parse_uint(str, &val, &endptr, 0) == 0 && val <= UINT64_MAX) { | |
443 | if (*endptr == '\0') { | |
444 | *obj = val; | |
445 | processed(ov, name); | |
446 | return; | |
447 | } | |
448 | if (*endptr == '-' && ov->list_mode == LM_IN_PROGRESS) { | |
449 | unsigned long long val2; | |
450 | ||
451 | str = endptr + 1; | |
452 | if (parse_uint_full(str, &val2, 0) == 0 && | |
15a849be LE |
453 | val2 <= UINT64_MAX && val <= val2 && |
454 | val2 - val < OPTS_VISITOR_RANGE_MAX) { | |
581a8a80 LE |
455 | ov->range_next.u = val; |
456 | ov->range_limit.u = val2; | |
457 | ov->list_mode = LM_UNSIGNED_INTERVAL; | |
458 | ||
459 | /* as if entering on the top */ | |
460 | *obj = ov->range_next.u; | |
461 | return; | |
462 | } | |
463 | } | |
eb7ee2cb | 464 | } |
c6bd8c70 MA |
465 | error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name, |
466 | (ov->list_mode == LM_NONE) ? "a uint64 value" : | |
467 | "a uint64 value or range"); | |
eb7ee2cb LE |
468 | } |
469 | ||
470 | ||
471 | static void | |
0b2a0d6b | 472 | opts_type_size(Visitor *v, const char *name, uint64_t *obj, Error **errp) |
eb7ee2cb | 473 | { |
d7bea75d | 474 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
475 | const QemuOpt *opt; |
476 | int64_t val; | |
477 | char *endptr; | |
478 | ||
479 | opt = lookup_scalar(ov, name, errp); | |
480 | if (!opt) { | |
481 | return; | |
482 | } | |
483 | ||
4677bb40 MAL |
484 | val = qemu_strtosz_suffix(opt->str ? opt->str : "", &endptr, |
485 | QEMU_STRTOSZ_DEFSUFFIX_B); | |
cb45de67 | 486 | if (val < 0 || *endptr) { |
c6bd8c70 MA |
487 | error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name, |
488 | "a size value representible as a non-negative int64"); | |
eb7ee2cb LE |
489 | return; |
490 | } | |
cb45de67 AK |
491 | |
492 | *obj = val; | |
493 | processed(ov, name); | |
eb7ee2cb LE |
494 | } |
495 | ||
496 | ||
497 | static void | |
0b2a0d6b | 498 | opts_optional(Visitor *v, const char *name, bool *present) |
eb7ee2cb | 499 | { |
d7bea75d | 500 | OptsVisitor *ov = to_ov(v); |
eb7ee2cb LE |
501 | |
502 | /* we only support a single mandatory scalar field in a list node */ | |
d9570434 | 503 | assert(ov->list_mode == LM_NONE); |
eb7ee2cb LE |
504 | *present = (lookup_distinct(ov, name, NULL) != NULL); |
505 | } | |
506 | ||
507 | ||
508 | OptsVisitor * | |
509 | opts_visitor_new(const QemuOpts *opts) | |
510 | { | |
511 | OptsVisitor *ov; | |
512 | ||
513 | ov = g_malloc0(sizeof *ov); | |
514 | ||
515 | ov->visitor.start_struct = &opts_start_struct; | |
516 | ov->visitor.end_struct = &opts_end_struct; | |
517 | ||
518 | ov->visitor.start_list = &opts_start_list; | |
519 | ov->visitor.next_list = &opts_next_list; | |
520 | ov->visitor.end_list = &opts_end_list; | |
521 | ||
522 | /* input_type_enum() covers both "normal" enums and union discriminators. | |
523 | * The union discriminator field is always generated as "type"; it should | |
524 | * match the "type" QemuOpt child of any QemuOpts. | |
525 | * | |
526 | * input_type_enum() will remove the looked-up key from the | |
527 | * "unprocessed_opts" hash even if the lookup fails, because the removal is | |
528 | * done earlier in opts_type_str(). This should be harmless. | |
529 | */ | |
530 | ov->visitor.type_enum = &input_type_enum; | |
531 | ||
4c40314a | 532 | ov->visitor.type_int64 = &opts_type_int64; |
eb7ee2cb LE |
533 | ov->visitor.type_uint64 = &opts_type_uint64; |
534 | ov->visitor.type_size = &opts_type_size; | |
535 | ov->visitor.type_bool = &opts_type_bool; | |
536 | ov->visitor.type_str = &opts_type_str; | |
537 | ||
538 | /* type_number() is not filled in, but this is not the first visitor to | |
539 | * skip some mandatory methods... */ | |
540 | ||
e2cd0f4f | 541 | ov->visitor.optional = &opts_optional; |
eb7ee2cb LE |
542 | |
543 | ov->opts_root = opts; | |
544 | ||
545 | return ov; | |
546 | } | |
547 | ||
548 | ||
549 | void | |
550 | opts_visitor_cleanup(OptsVisitor *ov) | |
551 | { | |
552 | if (ov->unprocessed_opts != NULL) { | |
553 | g_hash_table_destroy(ov->unprocessed_opts); | |
554 | } | |
555 | g_free(ov->fake_id_opt); | |
e36c8766 | 556 | g_free(ov); |
eb7ee2cb LE |
557 | } |
558 | ||
559 | ||
560 | Visitor * | |
561 | opts_get_visitor(OptsVisitor *ov) | |
562 | { | |
563 | return &ov->visitor; | |
564 | } |