Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
b84186ff
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b84186ff
编写于
6月 01, 2010
作者:
P
Pieter Noordhuis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix signedness errors in ziplist testing code
上级
6ddc908a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
24 deletion
+24
-24
ziplist.c
ziplist.c
+24
-24
未找到文件。
ziplist.c
浏览文件 @
b84186ff
...
...
@@ -584,10 +584,10 @@ void ziplistRepr(unsigned char *zl) {
unsigned
char
*
createList
()
{
unsigned
char
*
zl
=
ziplistNew
();
zl
=
ziplistPush
(
zl
,
"foo"
,
3
,
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
"quux"
,
4
,
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
"hello"
,
5
,
ZIPLIST_HEAD
);
zl
=
ziplistPush
(
zl
,
"1024"
,
4
,
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
"foo"
,
3
,
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
"quux"
,
4
,
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
"hello"
,
5
,
ZIPLIST_HEAD
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
"1024"
,
4
,
ZIPLIST_TAIL
);
return
zl
;
}
...
...
@@ -596,23 +596,23 @@ unsigned char *createIntList() {
char
buf
[
32
];
sprintf
(
buf
,
"100"
);
zl
=
ziplistPush
(
zl
,
buf
,
strlen
(
buf
),
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
buf
,
strlen
(
buf
),
ZIPLIST_TAIL
);
sprintf
(
buf
,
"128000"
);
zl
=
ziplistPush
(
zl
,
buf
,
strlen
(
buf
),
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
buf
,
strlen
(
buf
),
ZIPLIST_TAIL
);
sprintf
(
buf
,
"-100"
);
zl
=
ziplistPush
(
zl
,
buf
,
strlen
(
buf
),
ZIPLIST_HEAD
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
buf
,
strlen
(
buf
),
ZIPLIST_HEAD
);
sprintf
(
buf
,
"4294967296"
);
zl
=
ziplistPush
(
zl
,
buf
,
strlen
(
buf
),
ZIPLIST_HEAD
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
buf
,
strlen
(
buf
),
ZIPLIST_HEAD
);
sprintf
(
buf
,
"non integer"
);
zl
=
ziplistPush
(
zl
,
buf
,
strlen
(
buf
),
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
buf
,
strlen
(
buf
),
ZIPLIST_TAIL
);
sprintf
(
buf
,
"much much longer non integer"
);
zl
=
ziplistPush
(
zl
,
buf
,
strlen
(
buf
),
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
buf
,
strlen
(
buf
),
ZIPLIST_TAIL
);
return
zl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
unsigned
char
*
zl
,
*
p
;
char
*
entry
;
unsigned
char
*
entry
;
unsigned
int
elen
;
long
long
value
;
sds
s
;
...
...
@@ -852,19 +852,19 @@ int main(int argc, char **argv) {
printf
(
"Delete foo while iterating:
\n
"
);
{
zl
=
createList
();
p
=
ziplistIndex
(
zl
,
0
);
while
(
ziplistGet
(
p
,
&
entry
,
&
elen
,
&
value
))
{
if
(
entry
&&
strncmp
(
"foo"
,
entry
,
elen
)
==
0
)
{
p
=
ziplistIndex
(
zl
,
0
);
while
(
ziplistGet
(
p
,
&
entry
,
&
elen
,
&
value
))
{
if
(
entry
&&
strncmp
(
"foo"
,
(
char
*
)
entry
,
elen
)
==
0
)
{
printf
(
"Delete foo
\n
"
);
zl
=
ziplistDelete
(
zl
,
&
p
,
ZIPLIST_TAIL
);
zl
=
ziplistDelete
(
zl
,
&
p
);
}
else
{
printf
(
"Entry: "
);
if
(
entry
)
{
fwrite
(
entry
,
elen
,
1
,
stdout
);
}
else
{
printf
(
"%lld"
,
value
);
printf
(
"%lld"
,
value
);
}
p
=
ziplistNext
(
p
);
p
=
ziplistNext
(
zl
,
p
);
printf
(
"
\n
"
);
}
}
...
...
@@ -879,7 +879,7 @@ int main(int argc, char **argv) {
int
i
,
len
;
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
len
=
sprintf
(
buf
,
"%d"
,
i
);
zl
=
ziplistPush
(
zl
,
buf
,
len
,
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
(
unsigned
char
*
)
buf
,
len
,
ZIPLIST_TAIL
);
}
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
p
=
ziplistIndex
(
zl
,
i
);
...
...
@@ -896,22 +896,22 @@ int main(int argc, char **argv) {
printf
(
"Compare strings with ziplist entries:
\n
"
);
{
zl
=
createList
();
p
=
ziplistIndex
(
zl
,
0
);
if
(
!
ziplistCompare
(
p
,
"hello"
,
5
))
{
p
=
ziplistIndex
(
zl
,
0
);
if
(
!
ziplistCompare
(
p
,
(
unsigned
char
*
)
"hello"
,
5
))
{
printf
(
"ERROR: not
\"
hello
\"\n
"
);
return
1
;
}
if
(
ziplistCompare
(
p
,
"hella"
,
5
))
{
if
(
ziplistCompare
(
p
,
(
unsigned
char
*
)
"hella"
,
5
))
{
printf
(
"ERROR:
\"
hella
\"\n
"
);
return
1
;
}
p
=
ziplistIndex
(
zl
,
3
);
if
(
!
ziplistCompare
(
p
,
"1024"
,
4
))
{
p
=
ziplistIndex
(
zl
,
3
);
if
(
!
ziplistCompare
(
p
,
(
unsigned
char
*
)
"1024"
,
4
))
{
printf
(
"ERROR: not
\"
1024
\"\n
"
);
return
1
;
}
if
(
ziplistCompare
(
p
,
"1025"
,
4
))
{
if
(
ziplistCompare
(
p
,
(
unsigned
char
*
)
"1025"
,
4
))
{
printf
(
"ERROR:
\"
1025
\"\n
"
);
return
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录