qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] readline: use g_strndup instead of open-coding it
@ 2014-05-05  9:25 Michael Tokarev
  2014-05-05  9:39 ` Andreas Färber
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Tokarev @ 2014-05-05  9:25 UTC (permalink / raw)
  To: qemu-trivial; +Cc: Michael Tokarev, qemu-devel

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 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);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-05  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-05  9:25 [Qemu-devel] [PATCH] readline: use g_strndup instead of open-coding it Michael Tokarev
2014-05-05  9:39 ` Andreas Färber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).