1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

bug 764: Convert sentinel to struct option

unregister_options() requires as a sentinel an instance of struct
option where option.name is NULL.  However, the NULL_OPTION_INFO macro
used for these sentinels actually initializes a struct option_init
instead.  Make register_options() overwrite the NULL_OPTION_INFO with
a sentinel in the correct format.  This probably makes a difference
only on platforms where null pointers don't have all bits zero.
(cherry picked from elinks-0.12 commit 8ac10e00d4)
This commit is contained in:
Kalle Olavi Niemitalo 2009-08-22 00:04:50 +03:00 committed by Kalle Olavi Niemitalo
parent 9e11e30fe3
commit cd0f6feec3

View File

@ -1241,11 +1241,19 @@ void
register_options(union option_info info[], struct option *tree)
{
int i;
static const struct option zero = INIT_OPTION(
NULL, 0, 0, 0, 0, 0, NULL, NULL);
/* To let unregister_options() correctly find the end of the
* info[] array, this loop must convert every element from
* struct option_init to struct option. That is, even if
* there is not enough memory to fully initialize some option,
* the loop must continue. */
for (i = 0; info[i].init.path; i++) {
static const struct option zero = INIT_OPTION(
NULL, 0, 0, 0, 0, 0, NULL, NULL);
/* Copy the value aside before it is overwritten
* with the other member of the union. */
const struct option_init init = info[i].init;
struct option *option = &info[i].option;
unsigned char *string;
@ -1321,6 +1329,9 @@ register_options(union option_info info[], struct option *tree)
add_opt_rec(tree, init.path, option);
}
/* Convert the sentinel at the end of the array, too. */
info[i].option = zero;
}
/*! @relates option_info */