[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH] readline: use g_strndup instead
From: |
Andreas Färber |
Subject: |
Re: [Qemu-trivial] [Qemu-devel] [PATCH] readline: use g_strndup instead of open-coding it |
Date: |
Mon, 05 May 2014 11:39:19 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
Am 05.05.2014 11:25, schrieb Michael Tokarev:
> Signed-off-by: Michael Tokarev <address@hidden>
> ---
> util/readline.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/util/readline.c b/util/readline.c
> index 8441be4..a3fd2cb 100644
> --- a/util/readline.c
> +++ b/util/readline.c
> @@ -279,9 +279,7 @@ static void readline_completion(ReadLineState *rs)
>
> rs->nb_completions = 0;
>
> - cmdline = g_malloc(rs->cmd_buf_index + 1);
> - memcpy(cmdline, rs->cmd_buf, rs->cmd_buf_index);
> - cmdline[rs->cmd_buf_index] = '\0';
> + cmdline = g_strndup(rs->cmd_buf, rs->cmd_buf_index);
> rs->completion_finder(rs->opaque, cmdline);
> g_free(cmdline);
>
Reviewed-by: Andreas Färber <address@hidden>
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg