1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

commands: refactor memset

Move memset() to the initialization function define_commands().

There is also not much point in clearing memory on command's exit
so drop zeroing of ~2M of RAM.
This commit is contained in:
Zdenek Kabelac 2024-03-24 22:44:53 +01:00
parent e450ad287e
commit e36c6a31e6
2 changed files with 2 additions and 5 deletions

View File

@ -1451,6 +1451,8 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
int skip = 0;
int i;
memset(&commands, 0, sizeof(commands));
if (run_name && !strcmp(run_name, "help"))
run_name = NULL;
@ -3934,8 +3936,6 @@ int main(int argc, char *argv[])
{0, 0, 0, 0 }
};
memset(&commands, 0, sizeof(commands));
if (!(stdout_buf = malloc(sz)))
log_error("Failed to allocate stdout buffer; carrying on with default buffering.");
else

View File

@ -1342,7 +1342,6 @@ static void _unregister_commands(void)
_cmdline.num_commands = 0;
_cmdline.command_names = NULL;
_cmdline.num_command_names = 0;
memset(&commands, 0, sizeof(commands));
}
static int _command_name_compare(const void *on1, const void *on2)
@ -1363,8 +1362,6 @@ int lvm_register_commands(struct cmd_context *cmd, const char *run_name)
if (_cmdline.commands)
return 1;
memset(&commands, 0, sizeof(commands));
/*
* populate commands[] array with command definitions
* by parsing command-lines.in/command-lines-input.h