Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hanoi2005
redis
提交
3fa19b7d
R
redis
项目概览
hanoi2005
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
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,发现更多精彩内容 >>
提交
3fa19b7d
编写于
2月 09, 2012
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ziplist.c endianess fixes, chapter 3.
上级
8e0ef249
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
21 addition
and
10 deletion
+21
-10
src/endian.h
src/endian.h
+3
-0
src/ziplist.c
src/ziplist.c
+18
-10
未找到文件。
src/endian.h
浏览文件 @
3fa19b7d
...
...
@@ -4,6 +4,9 @@
void
memrev16
(
void
*
p
);
void
memrev32
(
void
*
p
);
void
memrev64
(
void
*
p
);
uint16_t
intrev16
(
uint16_t
v
);
uint32_t
intrev32
(
uint32_t
v
);
uint64_t
intrev64
(
uint64_t
v
);
/* variants of the function doing the actual convertion only if the target
* host is big endian */
...
...
src/ziplist.c
浏览文件 @
3fa19b7d
...
...
@@ -99,7 +99,7 @@
* pushed one at a time. */
#define ZIPLIST_INCR_LENGTH(zl,incr) { \
if (ZIPLIST_LENGTH(zl) < UINT16_MAX) \
ZIPLIST_LENGTH(zl)
+= intrev16ifbe(
incr); \
ZIPLIST_LENGTH(zl)
= intrev16ifbe(intrev16ifbe(ZIPLIST_LENGTH(zl))+
incr); \
}
typedef
struct
zlentry
{
...
...
@@ -308,7 +308,7 @@ static int64_t zipLoadInteger(unsigned char *p, unsigned char encoding) {
ret
=
i32
;
}
else
if
(
encoding
==
ZIP_INT_64B
)
{
memcpy
(
&
i64
,
p
,
sizeof
(
i64
));
memrev
16
ifbe
(
&
i64
);
memrev
64
ifbe
(
&
i64
);
ret
=
i64
;
}
else
{
assert
(
NULL
);
...
...
@@ -403,8 +403,10 @@ static unsigned char *__ziplistCascadeUpdate(unsigned char *zl, unsigned char *p
noffset
=
np
-
zl
;
/* Update tail offset when next element is not the tail element. */
if
((
zl
+
intrev32ifbe
(
ZIPLIST_TAIL_OFFSET
(
zl
)))
!=
np
)
ZIPLIST_TAIL_OFFSET
(
zl
)
+=
intrev32ifbe
(
extra
);
if
((
zl
+
intrev32ifbe
(
ZIPLIST_TAIL_OFFSET
(
zl
)))
!=
np
)
{
ZIPLIST_TAIL_OFFSET
(
zl
)
=
intrev32ifbe
(
intrev32ifbe
(
ZIPLIST_TAIL_OFFSET
(
zl
))
+
extra
);
}
/* Move the tail to the back. */
memmove
(
np
+
rawlensize
,
...
...
@@ -455,14 +457,17 @@ static unsigned char *__ziplistDelete(unsigned char *zl, unsigned char *p, unsig
zipPrevEncodeLength
(
p
-
nextdiff
,
first
.
prevrawlen
);
/* Update offset for tail */
ZIPLIST_TAIL_OFFSET
(
zl
)
-=
intrev32ifbe
(
totlen
);
ZIPLIST_TAIL_OFFSET
(
zl
)
=
intrev32ifbe
(
intrev32ifbe
(
ZIPLIST_TAIL_OFFSET
(
zl
))
-
totlen
);
/* When the tail contains more than one entry, we need to take
* "nextdiff" in account as well. Otherwise, a change in the
* size of prevlen doesn't have an effect on the *tail* offset. */
tail
=
zipEntry
(
p
);
if
(
p
[
tail
.
headersize
+
tail
.
len
]
!=
ZIP_END
)
ZIPLIST_TAIL_OFFSET
(
zl
)
+=
intrev32ifbe
(
nextdiff
);
if
(
p
[
tail
.
headersize
+
tail
.
len
]
!=
ZIP_END
)
{
ZIPLIST_TAIL_OFFSET
(
zl
)
+=
intrev32ifbe
(
intrev32ifbe
(
ZIPLIST_TAIL_OFFSET
(
zl
))
+
nextdiff
);
}
/* Move tail to the front of the ziplist */
memmove
(
first
.
p
,
p
-
nextdiff
,
...
...
@@ -542,14 +547,17 @@ static unsigned char *__ziplistInsert(unsigned char *zl, unsigned char *p, unsig
zipPrevEncodeLength
(
p
+
reqlen
,
reqlen
);
/* Update offset for tail */
ZIPLIST_TAIL_OFFSET
(
zl
)
+=
intrev32ifbe
(
reqlen
);
ZIPLIST_TAIL_OFFSET
(
zl
)
=
intrev32ifbe
(
intrev32ifbe
(
ZIPLIST_TAIL_OFFSET
(
zl
))
+
reqlen
);
/* When the tail contains more than one entry, we need to take
* "nextdiff" in account as well. Otherwise, a change in the
* size of prevlen doesn't have an effect on the *tail* offset. */
tail
=
zipEntry
(
p
+
reqlen
);
if
(
p
[
reqlen
+
tail
.
headersize
+
tail
.
len
]
!=
ZIP_END
)
ZIPLIST_TAIL_OFFSET
(
zl
)
+=
intrev32ifbe
(
nextdiff
);
if
(
p
[
reqlen
+
tail
.
headersize
+
tail
.
len
]
!=
ZIP_END
)
{
ZIPLIST_TAIL_OFFSET
(
zl
)
=
intrev32ifbe
(
intrev32ifbe
(
ZIPLIST_TAIL_OFFSET
(
zl
))
+
nextdiff
);
}
}
else
{
/* This element will be the new tail. */
ZIPLIST_TAIL_OFFSET
(
zl
)
=
intrev32ifbe
(
p
-
zl
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录