patch 9.1.1692: global_functions are not constant
Problem: global_functions are not constant Solution: Place global_functions[] in read-only memory (Damien Lejay). Mark global_functions[] as `static const`. The table is never modified at runtime, so keeping it in writable `.data` has no benefit. Only a local pointer in func_check_arg_types() needed adjusting to `const`. No functional changes. closes: #18121 Signed-off-by: Damien Lejay <damien@lejay.be> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
0a9ad34cad
commit
93160530c4
@ -1934,7 +1934,7 @@ typedef struct
|
|||||||
# define TERM_FUNC(name) NULL
|
# define TERM_FUNC(name) NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static funcentry_T global_functions[] =
|
static const funcentry_T global_functions[] =
|
||||||
{
|
{
|
||||||
{"abs", 1, 1, FEARG_1, arg1_float_or_nr,
|
{"abs", 1, 1, FEARG_1, arg1_float_or_nr,
|
||||||
ret_any, f_abs},
|
ret_any, f_abs},
|
||||||
@ -3360,7 +3360,7 @@ internal_func_check_arg_types(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
argcheck_T *argchecks = global_functions[idx].f_argcheck;
|
const argcheck_T *argchecks = global_functions[idx].f_argcheck;
|
||||||
|
|
||||||
if (argchecks == NULL)
|
if (argchecks == NULL)
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ func Test_function_lists()
|
|||||||
" Create a file of the functions in evalfunc.c:global_functions[].
|
" Create a file of the functions in evalfunc.c:global_functions[].
|
||||||
enew!
|
enew!
|
||||||
read ../evalfunc.c
|
read ../evalfunc.c
|
||||||
1,/^static funcentry_T global_functions\[\] =$/d
|
1,/^static const funcentry_T global_functions\[\] =$/d
|
||||||
call search('^};$')
|
call search('^};$')
|
||||||
.,$d
|
.,$d
|
||||||
v/^ {/d
|
v/^ {/d
|
||||||
@ -38,7 +38,7 @@ func Test_function_lists()
|
|||||||
" not obsolete, sorted in ASCII order.
|
" not obsolete, sorted in ASCII order.
|
||||||
enew!
|
enew!
|
||||||
read ../evalfunc.c
|
read ../evalfunc.c
|
||||||
1,/^static funcentry_T global_functions\[\] =$/d
|
1,/^static const funcentry_T global_functions\[\] =$/d
|
||||||
call search('^};$')
|
call search('^};$')
|
||||||
.,$d
|
.,$d
|
||||||
v/^ {/d
|
v/^ {/d
|
||||||
|
|||||||
@ -724,6 +724,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1692,
|
||||||
/**/
|
/**/
|
||||||
1691,
|
1691,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user