Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b379c44c
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b379c44c
编写于
11月 28, 2016
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virstring: Introduce virStringListRemove
Signed-off-by:
N
Michal Privoznik
<
mprivozn@redhat.com
>
上级
ec38d6f7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
74 addition
and
0 deletion
+74
-0
src/libvirt_private.syms
src/libvirt_private.syms
+1
-0
src/util/virstring.c
src/util/virstring.c
+35
-0
src/util/virstring.h
src/util/virstring.h
+2
-0
tests/virstringtest.c
tests/virstringtest.c
+36
-0
未找到文件。
src/libvirt_private.syms
浏览文件 @
b379c44c
...
...
@@ -2467,6 +2467,7 @@ virStringListGetFirstWithPrefix;
virStringListHasString;
virStringListJoin;
virStringListLength;
virStringListRemove;
virStringReplace;
virStringSearch;
virStringSortCompare;
...
...
src/util/virstring.c
浏览文件 @
b379c44c
...
...
@@ -202,6 +202,41 @@ virStringListAdd(const char **strings,
}
/**
* virStringListRemove:
* @strings: a NULL-terminated array of strings
* @item: string to remove
*
* Remove every occurrence of @item in list of @strings.
*/
void
virStringListRemove
(
char
***
strings
,
const
char
*
item
)
{
size_t
r
,
w
=
0
;
if
(
!
strings
||
!*
strings
)
return
;
for
(
r
=
0
;
(
*
strings
)[
r
];
r
++
)
{
if
(
STREQ
((
*
strings
)[
r
],
item
))
{
VIR_FREE
((
*
strings
)[
r
]);
continue
;
}
if
(
r
!=
w
)
(
*
strings
)[
w
]
=
(
*
strings
)[
r
];
w
++
;
}
if
(
w
==
0
)
{
VIR_FREE
(
*
strings
);
}
else
{
(
*
strings
)[
w
]
=
NULL
;
ignore_value
(
VIR_REALLOC_N
(
*
strings
,
w
+
1
));
}
}
/**
* virStringListFree:
* @str_array: a NULL-terminated array of strings to free
...
...
src/util/virstring.h
浏览文件 @
b379c44c
...
...
@@ -43,6 +43,8 @@ char *virStringListJoin(const char **strings,
char
**
virStringListAdd
(
const
char
**
strings
,
const
char
*
item
);
void
virStringListRemove
(
char
***
strings
,
const
char
*
item
);
void
virStringListFree
(
char
**
strings
);
void
virStringListFreeCount
(
char
**
strings
,
...
...
tests/virstringtest.c
浏览文件 @
b379c44c
...
...
@@ -162,6 +162,40 @@ static int testAdd(const void *args)
}
static
int
testRemove
(
const
void
*
args
)
{
const
struct
testSplitData
*
data
=
args
;
char
**
list
=
NULL
;
size_t
ntokens
;
size_t
i
;
int
ret
=
-
1
;
if
(
!
(
list
=
virStringSplitCount
(
data
->
string
,
data
->
delim
,
data
->
max_tokens
,
&
ntokens
)))
{
VIR_DEBUG
(
"Got no tokens at all"
);
return
-
1
;
}
for
(
i
=
0
;
data
->
tokens
[
i
];
i
++
)
{
virStringListRemove
(
&
list
,
data
->
tokens
[
i
]);
if
(
virStringListHasString
((
const
char
**
)
list
,
data
->
tokens
[
i
]))
{
virFilePrintf
(
stderr
,
"Not removed %s"
,
data
->
tokens
[
i
]);
goto
cleanup
;
}
}
if
(
list
&&
list
[
0
])
{
virFilePrintf
(
stderr
,
"Not removed all tokens: %s"
,
list
[
0
]);
goto
cleanup
;
}
ret
=
0
;
cleanup:
virStringListFree
(
list
);
return
ret
;
}
static
bool
fail
;
static
const
char
*
...
...
@@ -636,6 +670,8 @@ mymain(void)
ret = -1; \
if (virTestRun("Add " #str, testAdd, &joinData) < 0) \
ret = -1; \
if (virTestRun("Remove " #str, testRemove, &splitData) < 0) \
ret = -1; \
} while (0)
const
char
*
tokens1
[]
=
{
NULL
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录