提交 f1ca0686 编写于 作者: C Cole Robinson

Move local argvToString to virArgvToString in util.

上级 7271a92b
Wed Nov 5 13:19:00 EST 2008 Cole Robinson <crobinso@redhat.com>
* src/iptables.c, src/util.c, src/util.h: Move local argvToString to
virArgvToString.
Wed Nov 5 15:22:12 CET 2008 Jim Meyering <meyering@redhat.com>
plug two leaks and fix a diagnostic
......
......@@ -384,32 +384,6 @@ iptRulesNew(const char *table,
return NULL;
}
static char *
argvToString(const char *const *argv)
{
int len, i;
char *ret, *p;
for (len = 1, i = 0; argv[i]; i++)
len += strlen(argv[i]) + 1;
if (VIR_ALLOC_N(ret, len) < 0)
return NULL;
p = ret;
for (i = 0; argv[i]; i++) {
if (i != 0)
*(p++) = ' ';
strcpy(p, argv[i]);
p += strlen(argv[i]);
}
*p = '\0';
return ret;
}
static int
iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...)
{
......@@ -464,7 +438,7 @@ iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...)
va_end(args);
if (!(rule = argvToString(&argv[command_idx])))
if (!(rule = virArgvToString(&argv[command_idx])))
goto error;
if (action == REMOVE) {
......
......@@ -87,6 +87,33 @@ int virFileStripSuffix(char *str,
return 1;
}
char *
virArgvToString(const char *const *argv)
{
int len, i;
char *ret, *p;
for (len = 1, i = 0; argv[i]; i++)
len += strlen(argv[i]) + 1;
if (VIR_ALLOC_N(ret, len) < 0)
return NULL;
p = ret;
for (i = 0; argv[i]; i++) {
if (i != 0)
*(p++) = ' ';
strcpy(p, argv[i]);
p += strlen(argv[i]);
}
*p = '\0';
return ret;
}
#ifndef __MINGW32__
static int virSetCloseExec(int fd) {
......
......@@ -88,6 +88,8 @@ int virFileReadPid(const char *dir,
int virFileDeletePid(const char *dir,
const char *name);
char *virArgvToString(const char *const *argv);
int __virStrToLong_i(char const *s,
char **end_ptr,
int base,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册