diff options
author | Richard Jones <rjones@redhat.com> | 2009-05-12 17:17:19 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-05-12 17:17:19 +0100 |
commit | b2a5fec5f8b8b6bf1313d8474448cd8b50057d1b (patch) | |
tree | 33cc222fb6eb2726c97b7268fba2b75601ea21e6 /daemon/command.c | |
parent | 45d78361d791f4a752fca9472b81bdc75f9f92a4 (diff) | |
download | libguestfs-b2a5fec5f8b8b6bf1313d8474448cd8b50057d1b.tar.gz libguestfs-b2a5fec5f8b8b6bf1313d8474448cd8b50057d1b.tar.xz libguestfs-b2a5fec5f8b8b6bf1313d8474448cd8b50057d1b.zip |
Refactor line splitting code in the daemon, and fix it so it works.
Diffstat (limited to 'daemon/command.c')
-rw-r--r-- | daemon/command.c | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/daemon/command.c b/daemon/command.c index 1daccf6e..1a50264b 100644 --- a/daemon/command.c +++ b/daemon/command.c @@ -84,37 +84,16 @@ char ** do_command_lines (char * const * const argv) { char *out; - char **lines = NULL; - int size = 0, alloc = 0; - char *p, *pend; + char **lines; out = do_command (argv); if (out == NULL) return NULL; - /* Now convert the output to a list of lines. */ - p = out; - while (p) { - pend = strchr (p, '\n'); - if (pend) { - *pend = '\0'; - pend++; - - /* Final \n? Don't return an empty final element. */ - if (*pend == '\0') break; - } - - if (add_string (&lines, &size, &alloc, p) == -1) { - free (out); - return NULL; - } - - p = pend; - } - + lines = split_lines (out); free (out); - if (add_string (&lines, &size, &alloc, NULL) == -1) + if (lines == NULL) return NULL; return lines; /* Caller frees. */ |