File src/engine/options.c changed (mode: 100644) (index c93d571b8..7eeae929d) |
... |
... |
typedef void (*mod_t)(char buffer[], char value); |
56 |
56 |
|
|
57 |
57 |
static opt_t * add_option_inner(const char name[], OPT_TYPE type, int val_count, |
static opt_t * add_option_inner(const char name[], OPT_TYPE type, int val_count, |
58 |
58 |
const char *vals[], opt_handler handler); |
const char *vals[], opt_handler handler); |
|
59 |
|
static int allocates_str_value(OPT_TYPE type); |
59 |
60 |
static void print_changed_options(void); |
static void print_changed_options(void); |
60 |
61 |
static int process_option(const char arg[]); |
static int process_option(const char arg[]); |
61 |
62 |
static int handle_all_pseudo(const char arg[], const char suffix[]); |
static int handle_all_pseudo(const char arg[], const char suffix[]); |
|
... |
... |
clear_options(void) |
141 |
142 |
for(i = 0U; i < options_count; ++i) |
for(i = 0U; i < options_count; ++i) |
142 |
143 |
{ |
{ |
143 |
144 |
free(options[i].name); |
free(options[i].name); |
144 |
|
if(options[i].type == OPT_STR || options[i].type == OPT_STRLIST) |
|
|
145 |
|
if(allocates_str_value(options[i].type)) |
145 |
146 |
{ |
{ |
146 |
147 |
if(options[i].full == NULL) |
if(options[i].full == NULL) |
147 |
148 |
free(options[i].def.str_val); |
free(options[i].def.str_val); |
|
... |
... |
add_option(const char name[], const char abbr[], OPT_TYPE type, int val_count, |
175 |
176 |
abbreviated->full = full_name; |
abbreviated->full = full_name; |
176 |
177 |
full = find_option(full_name); |
full = find_option(full_name); |
177 |
178 |
} |
} |
178 |
|
if(type == OPT_STR || type == OPT_STRLIST || type == OPT_CHARSET) |
|
|
179 |
|
if(allocates_str_value(type)) |
179 |
180 |
{ |
{ |
180 |
181 |
full->def.str_val = strdup(def.str_val); |
full->def.str_val = strdup(def.str_val); |
181 |
182 |
full->val.str_val = strdup(def.str_val); |
full->val.str_val = strdup(def.str_val); |
|
... |
... |
add_option_inner(const char name[], OPT_TYPE type, int val_count, |
233 |
234 |
return p; |
return p; |
234 |
235 |
} |
} |
235 |
236 |
|
|
|
237 |
|
/* Checks whether given option type allocates memory for strings on heap. |
|
238 |
|
* Returns non-zero if so, otherwise zero is returned. */ |
|
239 |
|
static int |
|
240 |
|
allocates_str_value(OPT_TYPE type) |
|
241 |
|
{ |
|
242 |
|
return (type == OPT_STR || type == OPT_STRLIST || type == OPT_CHARSET); |
|
243 |
|
} |
|
244 |
|
|
236 |
245 |
void |
void |
237 |
246 |
set_option(const char name[], optval_t val) |
set_option(const char name[], optval_t val) |
238 |
247 |
{ |
{ |