aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMichael Tokarev <mjt@tls.msk.ru>2014-05-05 13:23:50 +0400
committerMichael Tokarev <mjt@tls.msk.ru>2014-05-07 21:00:43 +0400
commit6ad7c326a1b62a71a83b46de79b8d8391bb768ff (patch)
treeccb4233a780fd5b5f0ef316dc06d6d010d006729 /util
parent797720876a5c24dd6adb3c2d6e0c872ac3b35c11 (diff)
readline: use g_strndup instead of open-coding it
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'util')
-rw-r--r--util/readline.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/util/readline.c b/util/readline.c
index 8441be484c..a3fd2cb466 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);