aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-08-23 22:49:48 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-08-23 22:49:48 +0200
commit8d12fe885db09e08313fbf15a943653c39dead97 (patch)
tree89badeaf73886447972195aa86b5e29622738b78 /src
parentcmd: add cmd_from_argv (diff)
downloadcimple-8d12fe885db09e08313fbf15a943653c39dead97.tar.gz
cimple-8d12fe885db09e08313fbf15a943653c39dead97.zip
remove redundant code
Diffstat (limited to 'src')
-rw-r--r--src/cmd.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/cmd.c b/src/cmd.c
index f84cb32..3a235db 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -67,9 +67,6 @@ static void arr_pack(char *dest, int argc, char **argv)
static int arr_unpack(char **argv, int argc, const char *src)
{
- for (int i = 0; i < argc; ++i)
- argv[i] = NULL;
-
for (int i = 0; i < argc; ++i) {
size_t len = strlen(src);
@@ -143,13 +140,12 @@ int cmd_recv(int fd, struct cmd *cmd)
return ret;
cmd->argc = calc_arr_len(buf, len);
- cmd->argv = malloc(cmd->argc * sizeof(char *));
+ cmd->argv = calloc(cmd->argc, sizeof(char *));
if (!cmd->argv) {
- print_errno("malloc");
+ print_errno("calloc");
ret = -1;
goto free_buf;
}
- memset(cmd->argv, 0, cmd->argc * sizeof(char *));
ret = arr_unpack(cmd->argv, cmd->argc, buf);
if (ret < 0)