Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
8f3a4df7
R
redis
项目概览
Turbo码先生
/
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,发现更多精彩内容 >>
提交
8f3a4df7
编写于
6月 20, 2016
作者:
Y
Yossi Gottlieb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use const in Redis Module API where possible.
上级
0b4b7ebd
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
38 addition
and
38 deletion
+38
-38
src/debug.c
src/debug.c
+7
-7
src/intset.c
src/intset.c
+1
-1
src/intset.h
src/intset.h
+1
-1
src/module.c
src/module.c
+3
-3
src/object.c
src/object.c
+2
-2
src/quicklist.c
src/quicklist.c
+1
-1
src/quicklist.h
src/quicklist.h
+1
-1
src/redismodule.h
src/redismodule.h
+3
-3
src/server.h
src/server.h
+11
-11
src/t_hash.c
src/t_hash.c
+2
-2
src/t_list.c
src/t_list.c
+1
-1
src/t_set.c
src/t_set.c
+3
-3
src/t_zset.c
src/t_zset.c
+2
-2
未找到文件。
src/debug.c
浏览文件 @
8f3a4df7
...
...
@@ -550,7 +550,7 @@ void debugCommand(client *c) {
/* =========================== Crash handling ============================== */
void
_serverAssert
(
c
har
*
estr
,
char
*
file
,
int
line
)
{
void
_serverAssert
(
c
onst
char
*
estr
,
const
char
*
file
,
int
line
)
{
bugReportStart
();
serverLog
(
LL_WARNING
,
"=== ASSERTION FAILED ==="
);
serverLog
(
LL_WARNING
,
"==> %s:%d '%s' is not true"
,
file
,
line
,
estr
);
...
...
@@ -563,7 +563,7 @@ void _serverAssert(char *estr, char *file, int line) {
*
((
char
*
)
-
1
)
=
'x'
;
}
void
_serverAssertPrintClientInfo
(
client
*
c
)
{
void
_serverAssertPrintClientInfo
(
c
onst
c
lient
*
c
)
{
int
j
;
bugReportStart
();
...
...
@@ -587,7 +587,7 @@ void _serverAssertPrintClientInfo(client *c) {
}
}
void
serverLogObjectDebugInfo
(
robj
*
o
)
{
void
serverLogObjectDebugInfo
(
const
robj
*
o
)
{
serverLog
(
LL_WARNING
,
"Object type: %d"
,
o
->
type
);
serverLog
(
LL_WARNING
,
"Object encoding: %d"
,
o
->
encoding
);
serverLog
(
LL_WARNING
,
"Object refcount: %d"
,
o
->
refcount
);
...
...
@@ -607,23 +607,23 @@ void serverLogObjectDebugInfo(robj *o) {
}
else
if
(
o
->
type
==
OBJ_ZSET
)
{
serverLog
(
LL_WARNING
,
"Sorted set size: %d"
,
(
int
)
zsetLength
(
o
));
if
(
o
->
encoding
==
OBJ_ENCODING_SKIPLIST
)
serverLog
(
LL_WARNING
,
"Skiplist level: %d"
,
(
int
)
((
zset
*
)
o
->
ptr
)
->
zsl
->
level
);
serverLog
(
LL_WARNING
,
"Skiplist level: %d"
,
(
int
)
((
const
zset
*
)
o
->
ptr
)
->
zsl
->
level
);
}
}
void
_serverAssertPrintObject
(
robj
*
o
)
{
void
_serverAssertPrintObject
(
const
robj
*
o
)
{
bugReportStart
();
serverLog
(
LL_WARNING
,
"=== ASSERTION FAILED OBJECT CONTEXT ==="
);
serverLogObjectDebugInfo
(
o
);
}
void
_serverAssertWithInfo
(
c
lient
*
c
,
robj
*
o
,
char
*
estr
,
char
*
file
,
int
line
)
{
void
_serverAssertWithInfo
(
c
onst
client
*
c
,
const
robj
*
o
,
const
char
*
estr
,
const
char
*
file
,
int
line
)
{
if
(
c
)
_serverAssertPrintClientInfo
(
c
);
if
(
o
)
_serverAssertPrintObject
(
o
);
_serverAssert
(
estr
,
file
,
line
);
}
void
_serverPanic
(
c
har
*
msg
,
char
*
file
,
int
line
)
{
void
_serverPanic
(
c
onst
char
*
msg
,
const
char
*
file
,
int
line
)
{
bugReportStart
();
serverLog
(
LL_WARNING
,
"------------------------------------------------"
);
serverLog
(
LL_WARNING
,
"!!! Software Failure. Press left mouse button to continue"
);
...
...
src/intset.c
浏览文件 @
8f3a4df7
...
...
@@ -272,7 +272,7 @@ uint8_t intsetGet(intset *is, uint32_t pos, int64_t *value) {
}
/* Return intset length */
uint32_t
intsetLen
(
intset
*
is
)
{
uint32_t
intsetLen
(
const
intset
*
is
)
{
return
intrev32ifbe
(
is
->
length
);
}
...
...
src/intset.h
浏览文件 @
8f3a4df7
...
...
@@ -44,7 +44,7 @@ intset *intsetRemove(intset *is, int64_t value, int *success);
uint8_t
intsetFind
(
intset
*
is
,
int64_t
value
);
int64_t
intsetRandom
(
intset
*
is
);
uint8_t
intsetGet
(
intset
*
is
,
uint32_t
pos
,
int64_t
*
value
);
uint32_t
intsetLen
(
intset
*
is
);
uint32_t
intsetLen
(
const
intset
*
is
);
size_t
intsetBlobLen
(
intset
*
is
);
#ifdef REDIS_TEST
...
...
src/module.c
浏览文件 @
8f3a4df7
...
...
@@ -687,7 +687,7 @@ void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str) {
/* Given a string module object, this function returns the string pointer
* and length of the string. The returned pointer and length should only
* be used for read only accesses and never modified. */
const
char
*
RM_StringPtrLen
(
RedisModuleString
*
str
,
size_t
*
len
)
{
const
char
*
RM_StringPtrLen
(
const
RedisModuleString
*
str
,
size_t
*
len
)
{
if
(
len
)
*
len
=
sdslen
(
str
->
ptr
);
return
str
->
ptr
;
}
...
...
@@ -696,7 +696,7 @@ const char *RM_StringPtrLen(RedisModuleString *str, size_t *len) {
* Returns REDISMODULE_OK on success. If the string can't be parsed
* as a valid, strict long long (no spaces before/after), REDISMODULE_ERR
* is returned. */
int
RM_StringToLongLong
(
RedisModuleString
*
str
,
long
long
*
ll
)
{
int
RM_StringToLongLong
(
const
RedisModuleString
*
str
,
long
long
*
ll
)
{
return
string2ll
(
str
->
ptr
,
sdslen
(
str
->
ptr
),
ll
)
?
REDISMODULE_OK
:
REDISMODULE_ERR
;
}
...
...
@@ -704,7 +704,7 @@ int RM_StringToLongLong(RedisModuleString *str, long long *ll) {
/* Convert the string into a double, storing it at `*d`.
* Returns REDISMODULE_OK on success or REDISMODULE_ERR if the string is
* not a valid string representation of a double value. */
int
RM_StringToDouble
(
RedisModuleString
*
str
,
double
*
d
)
{
int
RM_StringToDouble
(
const
RedisModuleString
*
str
,
double
*
d
)
{
int
retval
=
getDoubleFromObject
(
str
,
d
);
return
(
retval
==
C_OK
)
?
REDISMODULE_OK
:
REDISMODULE_ERR
;
}
...
...
src/object.c
浏览文件 @
8f3a4df7
...
...
@@ -539,7 +539,7 @@ size_t stringObjectLen(robj *o) {
}
}
int
getDoubleFromObject
(
robj
*
o
,
double
*
target
)
{
int
getDoubleFromObject
(
const
robj
*
o
,
double
*
target
)
{
double
value
;
char
*
eptr
;
...
...
@@ -550,7 +550,7 @@ int getDoubleFromObject(robj *o, double *target) {
if
(
sdsEncodedObject
(
o
))
{
errno
=
0
;
value
=
strtod
(
o
->
ptr
,
&
eptr
);
if
(
isspace
(((
char
*
)
o
->
ptr
)[
0
])
||
if
(
isspace
(((
c
onst
c
har
*
)
o
->
ptr
)[
0
])
||
eptr
[
0
]
!=
'\0'
||
(
errno
==
ERANGE
&&
(
value
==
HUGE_VAL
||
value
==
-
HUGE_VAL
||
value
==
0
))
||
...
...
src/quicklist.c
浏览文件 @
8f3a4df7
...
...
@@ -149,7 +149,7 @@ REDIS_STATIC quicklistNode *quicklistCreateNode(void) {
}
/* Return cached quicklist count */
unsigned
int
quicklistCount
(
quicklist
*
ql
)
{
return
ql
->
count
;
}
unsigned
int
quicklistCount
(
const
quicklist
*
ql
)
{
return
ql
->
count
;
}
/* Free entire quicklist. */
void
quicklistRelease
(
quicklist
*
quicklist
)
{
...
...
src/quicklist.h
浏览文件 @
8f3a4df7
...
...
@@ -154,7 +154,7 @@ int quicklistPopCustom(quicklist *quicklist, int where, unsigned char **data,
void
*
(
*
saver
)(
unsigned
char
*
data
,
unsigned
int
sz
));
int
quicklistPop
(
quicklist
*
quicklist
,
int
where
,
unsigned
char
**
data
,
unsigned
int
*
sz
,
long
long
*
slong
);
unsigned
int
quicklistCount
(
quicklist
*
ql
);
unsigned
int
quicklistCount
(
const
quicklist
*
ql
);
int
quicklistCompare
(
unsigned
char
*
p1
,
unsigned
char
*
p2
,
int
p2_len
);
size_t
quicklistGetLzf
(
const
quicklistNode
*
node
,
void
**
data
);
...
...
src/redismodule.h
浏览文件 @
8f3a4df7
...
...
@@ -123,7 +123,7 @@ RedisModuleCallReply *REDISMODULE_API_FUNC(RedisModule_CallReplyArrayElement)(Re
RedisModuleString
*
REDISMODULE_API_FUNC
(
RedisModule_CreateString
)(
RedisModuleCtx
*
ctx
,
const
char
*
ptr
,
size_t
len
);
RedisModuleString
*
REDISMODULE_API_FUNC
(
RedisModule_CreateStringFromLongLong
)(
RedisModuleCtx
*
ctx
,
long
long
ll
);
void
REDISMODULE_API_FUNC
(
RedisModule_FreeString
)(
RedisModuleCtx
*
ctx
,
RedisModuleString
*
str
);
const
char
*
REDISMODULE_API_FUNC
(
RedisModule_StringPtrLen
)(
RedisModuleString
*
str
,
size_t
*
len
);
const
char
*
REDISMODULE_API_FUNC
(
RedisModule_StringPtrLen
)(
const
RedisModuleString
*
str
,
size_t
*
len
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithError
)(
RedisModuleCtx
*
ctx
,
const
char
*
err
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithSimpleString
)(
RedisModuleCtx
*
ctx
,
const
char
*
msg
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithArray
)(
RedisModuleCtx
*
ctx
,
long
len
);
...
...
@@ -133,8 +133,8 @@ int REDISMODULE_API_FUNC(RedisModule_ReplyWithString)(RedisModuleCtx *ctx, Redis
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithNull
)(
RedisModuleCtx
*
ctx
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithDouble
)(
RedisModuleCtx
*
ctx
,
double
d
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithCallReply
)(
RedisModuleCtx
*
ctx
,
RedisModuleCallReply
*
reply
);
int
REDISMODULE_API_FUNC
(
RedisModule_StringToLongLong
)(
RedisModuleString
*
str
,
long
long
*
ll
);
int
REDISMODULE_API_FUNC
(
RedisModule_StringToDouble
)(
RedisModuleString
*
str
,
double
*
d
);
int
REDISMODULE_API_FUNC
(
RedisModule_StringToLongLong
)(
const
RedisModuleString
*
str
,
long
long
*
ll
);
int
REDISMODULE_API_FUNC
(
RedisModule_StringToDouble
)(
const
RedisModuleString
*
str
,
double
*
d
);
void
REDISMODULE_API_FUNC
(
RedisModule_AutoMemory
)(
RedisModuleCtx
*
ctx
);
int
REDISMODULE_API_FUNC
(
RedisModule_Replicate
)(
RedisModuleCtx
*
ctx
,
const
char
*
cmdname
,
const
char
*
fmt
,
...);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplicateVerbatim
)(
RedisModuleCtx
*
ctx
);
...
...
src/server.h
浏览文件 @
8f3a4df7
...
...
@@ -1048,8 +1048,8 @@ struct redisServer {
long
long
latency_monitor_threshold
;
dict
*
latency_events
;
/* Assert & bug reporting */
char
*
assert_failed
;
char
*
assert_file
;
c
onst
c
har
*
assert_failed
;
c
onst
c
har
*
assert_file
;
int
assert_line
;
int
bug_report_start
;
/* True if bug report header was already logged. */
int
watchdog_period
;
/* Software watchdog period in ms. 0 = off */
...
...
@@ -1245,7 +1245,7 @@ void addReplyStatusFormat(client *c, const char *fmt, ...);
void
listTypeTryConversion
(
robj
*
subject
,
robj
*
value
);
void
listTypePush
(
robj
*
subject
,
robj
*
value
,
int
where
);
robj
*
listTypePop
(
robj
*
subject
,
int
where
);
unsigned
long
listTypeLength
(
robj
*
subject
);
unsigned
long
listTypeLength
(
const
robj
*
subject
);
listTypeIterator
*
listTypeInitIterator
(
robj
*
subject
,
long
index
,
unsigned
char
direction
);
void
listTypeReleaseIterator
(
listTypeIterator
*
li
);
int
listTypeNext
(
listTypeIterator
*
li
,
listTypeEntry
*
entry
);
...
...
@@ -1305,7 +1305,7 @@ int getLongFromObjectOrReply(client *c, robj *o, long *target, const char *msg);
int
checkType
(
client
*
c
,
robj
*
o
,
int
type
);
int
getLongLongFromObjectOrReply
(
client
*
c
,
robj
*
o
,
long
long
*
target
,
const
char
*
msg
);
int
getDoubleFromObjectOrReply
(
client
*
c
,
robj
*
o
,
double
*
target
,
const
char
*
msg
);
int
getDoubleFromObject
(
robj
*
o
,
double
*
target
);
int
getDoubleFromObject
(
const
robj
*
o
,
double
*
target
);
int
getLongLongFromObject
(
robj
*
o
,
long
long
*
target
);
int
getLongDoubleFromObject
(
robj
*
o
,
long
double
*
target
);
int
getLongDoubleFromObjectOrReply
(
client
*
c
,
robj
*
o
,
long
double
*
target
,
const
char
*
msg
);
...
...
@@ -1406,7 +1406,7 @@ void zzlNext(unsigned char *zl, unsigned char **eptr, unsigned char **sptr);
void
zzlPrev
(
unsigned
char
*
zl
,
unsigned
char
**
eptr
,
unsigned
char
**
sptr
);
unsigned
char
*
zzlFirstInRange
(
unsigned
char
*
zl
,
zrangespec
*
range
);
unsigned
char
*
zzlLastInRange
(
unsigned
char
*
zl
,
zrangespec
*
range
);
unsigned
int
zsetLength
(
robj
*
zobj
);
unsigned
int
zsetLength
(
const
robj
*
zobj
);
void
zsetConvert
(
robj
*
zobj
,
int
encoding
);
void
zsetConvertToZiplistIfNeeded
(
robj
*
zobj
,
size_t
maxelelen
);
int
zsetScore
(
robj
*
zobj
,
sds
member
,
double
*
score
);
...
...
@@ -1479,7 +1479,7 @@ int setTypeNext(setTypeIterator *si, sds *sdsele, int64_t *llele);
sds
setTypeNextObject
(
setTypeIterator
*
si
);
int
setTypeRandomElement
(
robj
*
setobj
,
sds
*
sdsele
,
int64_t
*
llele
);
unsigned
long
setTypeRandomElements
(
robj
*
set
,
unsigned
long
count
,
robj
*
aux_set
);
unsigned
long
setTypeSize
(
robj
*
subject
);
unsigned
long
setTypeSize
(
const
robj
*
subject
);
void
setTypeConvert
(
robj
*
subject
,
int
enc
);
/* Hash data type */
...
...
@@ -1492,7 +1492,7 @@ void hashTypeTryConversion(robj *subject, robj **argv, int start, int end);
void
hashTypeTryObjectEncoding
(
robj
*
subject
,
robj
**
o1
,
robj
**
o2
);
int
hashTypeExists
(
robj
*
o
,
sds
key
);
int
hashTypeDelete
(
robj
*
o
,
sds
key
);
unsigned
long
hashTypeLength
(
robj
*
o
);
unsigned
long
hashTypeLength
(
const
robj
*
o
);
hashTypeIterator
*
hashTypeInitIterator
(
robj
*
subject
);
void
hashTypeReleaseIterator
(
hashTypeIterator
*
hi
);
int
hashTypeNext
(
hashTypeIterator
*
hi
);
...
...
@@ -1799,11 +1799,11 @@ void *realloc(void *ptr, size_t size) __attribute__ ((deprecated));
#endif
/* Debugging stuff */
void
_serverAssertWithInfo
(
c
lient
*
c
,
robj
*
o
,
char
*
estr
,
char
*
file
,
int
line
);
void
_serverAssert
(
c
har
*
estr
,
char
*
file
,
int
line
);
void
_serverPanic
(
c
har
*
msg
,
char
*
file
,
int
line
);
void
_serverAssertWithInfo
(
c
onst
client
*
c
,
const
robj
*
o
,
const
char
*
estr
,
const
char
*
file
,
int
line
);
void
_serverAssert
(
c
onst
char
*
estr
,
const
char
*
file
,
int
line
);
void
_serverPanic
(
c
onst
char
*
msg
,
const
char
*
file
,
int
line
);
void
bugReportStart
(
void
);
void
serverLogObjectDebugInfo
(
robj
*
o
);
void
serverLogObjectDebugInfo
(
const
robj
*
o
);
void
sigsegvHandler
(
int
sig
,
siginfo_t
*
info
,
void
*
secret
);
sds
genRedisInfoString
(
char
*
section
);
void
enableWatchdog
(
int
period
);
...
...
src/t_hash.c
浏览文件 @
8f3a4df7
...
...
@@ -308,13 +308,13 @@ int hashTypeDelete(robj *o, sds field) {
}
/* Return the number of elements in a hash. */
unsigned
long
hashTypeLength
(
robj
*
o
)
{
unsigned
long
hashTypeLength
(
const
robj
*
o
)
{
unsigned
long
length
=
ULONG_MAX
;
if
(
o
->
encoding
==
OBJ_ENCODING_ZIPLIST
)
{
length
=
ziplistLen
(
o
->
ptr
)
/
2
;
}
else
if
(
o
->
encoding
==
OBJ_ENCODING_HT
)
{
length
=
dictSize
((
dict
*
)
o
->
ptr
);
length
=
dictSize
((
const
dict
*
)
o
->
ptr
);
}
else
{
serverPanic
(
"Unknown hash encoding"
);
}
...
...
src/t_list.c
浏览文件 @
8f3a4df7
...
...
@@ -71,7 +71,7 @@ robj *listTypePop(robj *subject, int where) {
return
value
;
}
unsigned
long
listTypeLength
(
robj
*
subject
)
{
unsigned
long
listTypeLength
(
const
robj
*
subject
)
{
if
(
subject
->
encoding
==
OBJ_ENCODING_QUICKLIST
)
{
return
quicklistCount
(
subject
->
ptr
);
}
else
{
...
...
src/t_set.c
浏览文件 @
8f3a4df7
...
...
@@ -219,11 +219,11 @@ int setTypeRandomElement(robj *setobj, sds *sdsele, int64_t *llele) {
return
setobj
->
encoding
;
}
unsigned
long
setTypeSize
(
robj
*
subject
)
{
unsigned
long
setTypeSize
(
const
robj
*
subject
)
{
if
(
subject
->
encoding
==
OBJ_ENCODING_HT
)
{
return
dictSize
((
dict
*
)
subject
->
ptr
);
return
dictSize
((
const
dict
*
)
subject
->
ptr
);
}
else
if
(
subject
->
encoding
==
OBJ_ENCODING_INTSET
)
{
return
intsetLen
((
intset
*
)
subject
->
ptr
);
return
intsetLen
((
const
intset
*
)
subject
->
ptr
);
}
else
{
serverPanic
(
"Unknown set encoding"
);
}
...
...
src/t_zset.c
浏览文件 @
8f3a4df7
...
...
@@ -1100,12 +1100,12 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig
* Common sorted set API
*----------------------------------------------------------------------------*/
unsigned
int
zsetLength
(
robj
*
zobj
)
{
unsigned
int
zsetLength
(
const
robj
*
zobj
)
{
int
length
=
-
1
;
if
(
zobj
->
encoding
==
OBJ_ENCODING_ZIPLIST
)
{
length
=
zzlLength
(
zobj
->
ptr
);
}
else
if
(
zobj
->
encoding
==
OBJ_ENCODING_SKIPLIST
)
{
length
=
((
zset
*
)
zobj
->
ptr
)
->
zsl
->
length
;
length
=
((
const
zset
*
)
zobj
->
ptr
)
->
zsl
->
length
;
}
else
{
serverPanic
(
"Unknown sorted set encoding"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录