diff options
author | wm4 <wm4@nowhere> | 2018-01-10 01:20:58 +0100 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2018-01-10 20:36:27 -0800 |
commit | 2d345c59d637ec12fbc39d97e1999c335dffcdd2 (patch) | |
tree | ec8281b2e0ccec14739827e28153f73b22fd26ed /input/cmd_list.c | |
parent | e3bee23fe4e0dc15ea2564b684572572f2393a15 (diff) | |
download | mpv-2d345c59d637ec12fbc39d97e1999c335dffcdd2.tar.bz2 mpv-2d345c59d637ec12fbc39d97e1999c335dffcdd2.tar.xz |
input: make command argument list a dynamic array
Replace the static array with dynamic memory allocation. This also
requires some code to honor mp_cmd.nargs more strictly. Generally
allocates more stuff.
Fixes #5375 (although we could also just raise the static limit).
Diffstat (limited to 'input/cmd_list.c')
-rw-r--r-- | input/cmd_list.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/input/cmd_list.c b/input/cmd_list.c index 333f2cb223..dc3dd68a61 100644 --- a/input/cmd_list.c +++ b/input/cmd_list.c @@ -39,7 +39,8 @@ * (ARG_INT, ARG_FLOAT, ARG_STRING) if any, then optional arguments * (OARG_INT(default), etc) if any. The command will be given the default * argument value if the user didn't give enough arguments to specify it. - * A command can take a maximum of MP_CMD_MAX_ARGS arguments. + * A command can take a maximum of MP_CMD_DEF_MAX_ARGS arguments, or more + * if the command uses varargs. */ #define ARG_INT OPT_INT(ARG(i), 0) @@ -363,7 +364,7 @@ void mp_print_cmd_list(struct mp_log *out) for (int i = 0; mp_cmds[i].name; i++) { const struct mp_cmd_def *def = &mp_cmds[i]; mp_info(out, "%-20.20s", def->name); - for (int j = 0; j < MP_CMD_MAX_ARGS && def->args[j].type; j++) { + for (int j = 0; j < MP_CMD_DEF_MAX_ARGS && def->args[j].type; j++) { const char *type = def->args[j].type->name; if (def->args[j].defval) mp_info(out, " [%s]", type); |