Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
8f3a4df7
Commit
8f3a4df7
authored
Jun 20, 2016
by
Yossi Gottlieb
Browse files
Use const in Redis Module API where possible.
parent
0b4b7ebd
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/debug.c
View file @
8f3a4df7
...
@@ -550,7 +550,7 @@ void debugCommand(client *c) {
...
@@ -550,7 +550,7 @@ void debugCommand(client *c) {
/* =========================== Crash handling ============================== */
/* =========================== Crash handling ============================== */
void
_serverAssert
(
char
*
estr
,
char
*
file
,
int
line
)
{
void
_serverAssert
(
const
char
*
estr
,
const
char
*
file
,
int
line
)
{
bugReportStart
();
bugReportStart
();
serverLog
(
LL_WARNING
,
"=== ASSERTION FAILED ==="
);
serverLog
(
LL_WARNING
,
"=== ASSERTION FAILED ==="
);
serverLog
(
LL_WARNING
,
"==> %s:%d '%s' is not true"
,
file
,
line
,
estr
);
serverLog
(
LL_WARNING
,
"==> %s:%d '%s' is not true"
,
file
,
line
,
estr
);
...
@@ -563,7 +563,7 @@ void _serverAssert(char *estr, char *file, int line) {
...
@@ -563,7 +563,7 @@ void _serverAssert(char *estr, char *file, int line) {
*
((
char
*
)
-
1
)
=
'x'
;
*
((
char
*
)
-
1
)
=
'x'
;
}
}
void
_serverAssertPrintClientInfo
(
client
*
c
)
{
void
_serverAssertPrintClientInfo
(
const
client
*
c
)
{
int
j
;
int
j
;
bugReportStart
();
bugReportStart
();
...
@@ -587,7 +587,7 @@ void _serverAssertPrintClientInfo(client *c) {
...
@@ -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 type: %d"
,
o
->
type
);
serverLog
(
LL_WARNING
,
"Object encoding: %d"
,
o
->
encoding
);
serverLog
(
LL_WARNING
,
"Object encoding: %d"
,
o
->
encoding
);
serverLog
(
LL_WARNING
,
"Object refcount: %d"
,
o
->
refcount
);
serverLog
(
LL_WARNING
,
"Object refcount: %d"
,
o
->
refcount
);
...
@@ -607,23 +607,23 @@ void serverLogObjectDebugInfo(robj *o) {
...
@@ -607,23 +607,23 @@ void serverLogObjectDebugInfo(robj *o) {
}
else
if
(
o
->
type
==
OBJ_ZSET
)
{
}
else
if
(
o
->
type
==
OBJ_ZSET
)
{
serverLog
(
LL_WARNING
,
"Sorted set size: %d"
,
(
int
)
zsetLength
(
o
));
serverLog
(
LL_WARNING
,
"Sorted set size: %d"
,
(
int
)
zsetLength
(
o
));
if
(
o
->
encoding
==
OBJ_ENCODING_SKIPLIST
)
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
();
bugReportStart
();
serverLog
(
LL_WARNING
,
"=== ASSERTION FAILED OBJECT CONTEXT ==="
);
serverLog
(
LL_WARNING
,
"=== ASSERTION FAILED OBJECT CONTEXT ==="
);
serverLogObjectDebugInfo
(
o
);
serverLogObjectDebugInfo
(
o
);
}
}
void
_serverAssertWithInfo
(
client
*
c
,
robj
*
o
,
char
*
estr
,
char
*
file
,
int
line
)
{
void
_serverAssertWithInfo
(
const
client
*
c
,
const
robj
*
o
,
const
char
*
estr
,
const
char
*
file
,
int
line
)
{
if
(
c
)
_serverAssertPrintClientInfo
(
c
);
if
(
c
)
_serverAssertPrintClientInfo
(
c
);
if
(
o
)
_serverAssertPrintObject
(
o
);
if
(
o
)
_serverAssertPrintObject
(
o
);
_serverAssert
(
estr
,
file
,
line
);
_serverAssert
(
estr
,
file
,
line
);
}
}
void
_serverPanic
(
char
*
msg
,
char
*
file
,
int
line
)
{
void
_serverPanic
(
const
char
*
msg
,
const
char
*
file
,
int
line
)
{
bugReportStart
();
bugReportStart
();
serverLog
(
LL_WARNING
,
"------------------------------------------------"
);
serverLog
(
LL_WARNING
,
"------------------------------------------------"
);
serverLog
(
LL_WARNING
,
"!!! Software Failure. Press left mouse button to continue"
);
serverLog
(
LL_WARNING
,
"!!! Software Failure. Press left mouse button to continue"
);
...
...
src/intset.c
View file @
8f3a4df7
...
@@ -272,7 +272,7 @@ uint8_t intsetGet(intset *is, uint32_t pos, int64_t *value) {
...
@@ -272,7 +272,7 @@ uint8_t intsetGet(intset *is, uint32_t pos, int64_t *value) {
}
}
/* Return intset length */
/* Return intset length */
uint32_t
intsetLen
(
intset
*
is
)
{
uint32_t
intsetLen
(
const
intset
*
is
)
{
return
intrev32ifbe
(
is
->
length
);
return
intrev32ifbe
(
is
->
length
);
}
}
...
...
src/intset.h
View file @
8f3a4df7
...
@@ -44,7 +44,7 @@ intset *intsetRemove(intset *is, int64_t value, int *success);
...
@@ -44,7 +44,7 @@ intset *intsetRemove(intset *is, int64_t value, int *success);
uint8_t
intsetFind
(
intset
*
is
,
int64_t
value
);
uint8_t
intsetFind
(
intset
*
is
,
int64_t
value
);
int64_t
intsetRandom
(
intset
*
is
);
int64_t
intsetRandom
(
intset
*
is
);
uint8_t
intsetGet
(
intset
*
is
,
uint32_t
pos
,
int64_t
*
value
);
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
);
size_t
intsetBlobLen
(
intset
*
is
);
#ifdef REDIS_TEST
#ifdef REDIS_TEST
...
...
src/module.c
View file @
8f3a4df7
...
@@ -687,7 +687,7 @@ void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str) {
...
@@ -687,7 +687,7 @@ void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str) {
/* Given a string module object, this function returns the string pointer
/* Given a string module object, this function returns the string pointer
* and length of the string. The returned pointer and length should only
* and length of the string. The returned pointer and length should only
* be used for read only accesses and never modified. */
* 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
);
if
(
len
)
*
len
=
sdslen
(
str
->
ptr
);
return
str
->
ptr
;
return
str
->
ptr
;
}
}
...
@@ -696,7 +696,7 @@ const char *RM_StringPtrLen(RedisModuleString *str, size_t *len) {
...
@@ -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
* Returns REDISMODULE_OK on success. If the string can't be parsed
* as a valid, strict long long (no spaces before/after), REDISMODULE_ERR
* as a valid, strict long long (no spaces before/after), REDISMODULE_ERR
* is returned. */
* 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
:
return
string2ll
(
str
->
ptr
,
sdslen
(
str
->
ptr
),
ll
)
?
REDISMODULE_OK
:
REDISMODULE_ERR
;
REDISMODULE_ERR
;
}
}
...
@@ -704,7 +704,7 @@ int RM_StringToLongLong(RedisModuleString *str, long long *ll) {
...
@@ -704,7 +704,7 @@ int RM_StringToLongLong(RedisModuleString *str, long long *ll) {
/* Convert the string into a double, storing it at `*d`.
/* Convert the string into a double, storing it at `*d`.
* Returns REDISMODULE_OK on success or REDISMODULE_ERR if the string is
* Returns REDISMODULE_OK on success or REDISMODULE_ERR if the string is
* not a valid string representation of a double value. */
* 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
);
int
retval
=
getDoubleFromObject
(
str
,
d
);
return
(
retval
==
C_OK
)
?
REDISMODULE_OK
:
REDISMODULE_ERR
;
return
(
retval
==
C_OK
)
?
REDISMODULE_OK
:
REDISMODULE_ERR
;
}
}
...
...
src/object.c
View file @
8f3a4df7
...
@@ -539,7 +539,7 @@ size_t stringObjectLen(robj *o) {
...
@@ -539,7 +539,7 @@ size_t stringObjectLen(robj *o) {
}
}
}
}
int
getDoubleFromObject
(
robj
*
o
,
double
*
target
)
{
int
getDoubleFromObject
(
const
robj
*
o
,
double
*
target
)
{
double
value
;
double
value
;
char
*
eptr
;
char
*
eptr
;
...
@@ -550,7 +550,7 @@ int getDoubleFromObject(robj *o, double *target) {
...
@@ -550,7 +550,7 @@ int getDoubleFromObject(robj *o, double *target) {
if
(
sdsEncodedObject
(
o
))
{
if
(
sdsEncodedObject
(
o
))
{
errno
=
0
;
errno
=
0
;
value
=
strtod
(
o
->
ptr
,
&
eptr
);
value
=
strtod
(
o
->
ptr
,
&
eptr
);
if
(
isspace
(((
char
*
)
o
->
ptr
)[
0
])
||
if
(
isspace
(((
const
char
*
)
o
->
ptr
)[
0
])
||
eptr
[
0
]
!=
'\0'
||
eptr
[
0
]
!=
'\0'
||
(
errno
==
ERANGE
&&
(
errno
==
ERANGE
&&
(
value
==
HUGE_VAL
||
value
==
-
HUGE_VAL
||
value
==
0
))
||
(
value
==
HUGE_VAL
||
value
==
-
HUGE_VAL
||
value
==
0
))
||
...
...
src/quicklist.c
View file @
8f3a4df7
...
@@ -149,7 +149,7 @@ REDIS_STATIC quicklistNode *quicklistCreateNode(void) {
...
@@ -149,7 +149,7 @@ REDIS_STATIC quicklistNode *quicklistCreateNode(void) {
}
}
/* Return cached quicklist count */
/* Return cached quicklist count */
unsigned
int
quicklistCount
(
quicklist
*
ql
)
{
return
ql
->
count
;
}
unsigned
int
quicklistCount
(
const
quicklist
*
ql
)
{
return
ql
->
count
;
}
/* Free entire quicklist. */
/* Free entire quicklist. */
void
quicklistRelease
(
quicklist
*
quicklist
)
{
void
quicklistRelease
(
quicklist
*
quicklist
)
{
...
...
src/quicklist.h
View file @
8f3a4df7
...
@@ -154,7 +154,7 @@ int quicklistPopCustom(quicklist *quicklist, int where, unsigned char **data,
...
@@ -154,7 +154,7 @@ int quicklistPopCustom(quicklist *quicklist, int where, unsigned char **data,
void
*
(
*
saver
)(
unsigned
char
*
data
,
unsigned
int
sz
));
void
*
(
*
saver
)(
unsigned
char
*
data
,
unsigned
int
sz
));
int
quicklistPop
(
quicklist
*
quicklist
,
int
where
,
unsigned
char
**
data
,
int
quicklistPop
(
quicklist
*
quicklist
,
int
where
,
unsigned
char
**
data
,
unsigned
int
*
sz
,
long
long
*
slong
);
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
);
int
quicklistCompare
(
unsigned
char
*
p1
,
unsigned
char
*
p2
,
int
p2_len
);
size_t
quicklistGetLzf
(
const
quicklistNode
*
node
,
void
**
data
);
size_t
quicklistGetLzf
(
const
quicklistNode
*
node
,
void
**
data
);
...
...
src/redismodule.h
View file @
8f3a4df7
...
@@ -123,7 +123,7 @@ RedisModuleCallReply *REDISMODULE_API_FUNC(RedisModule_CallReplyArrayElement)(Re
...
@@ -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_CreateString
)(
RedisModuleCtx
*
ctx
,
const
char
*
ptr
,
size_t
len
);
RedisModuleString
*
REDISMODULE_API_FUNC
(
RedisModule_CreateStringFromLongLong
)(
RedisModuleCtx
*
ctx
,
long
long
ll
);
RedisModuleString
*
REDISMODULE_API_FUNC
(
RedisModule_CreateStringFromLongLong
)(
RedisModuleCtx
*
ctx
,
long
long
ll
);
void
REDISMODULE_API_FUNC
(
RedisModule_FreeString
)(
RedisModuleCtx
*
ctx
,
RedisModuleString
*
str
);
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_ReplyWithError
)(
RedisModuleCtx
*
ctx
,
const
char
*
err
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithSimpleString
)(
RedisModuleCtx
*
ctx
,
const
char
*
msg
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithSimpleString
)(
RedisModuleCtx
*
ctx
,
const
char
*
msg
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithArray
)(
RedisModuleCtx
*
ctx
,
long
len
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithArray
)(
RedisModuleCtx
*
ctx
,
long
len
);
...
@@ -133,8 +133,8 @@ int REDISMODULE_API_FUNC(RedisModule_ReplyWithString)(RedisModuleCtx *ctx, Redis
...
@@ -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_ReplyWithNull
)(
RedisModuleCtx
*
ctx
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithDouble
)(
RedisModuleCtx
*
ctx
,
double
d
);
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_ReplyWithCallReply
)(
RedisModuleCtx
*
ctx
,
RedisModuleCallReply
*
reply
);
int
REDISMODULE_API_FUNC
(
RedisModule_StringToLongLong
)(
RedisModuleString
*
str
,
long
long
*
ll
);
int
REDISMODULE_API_FUNC
(
RedisModule_StringToLongLong
)(
const
RedisModuleString
*
str
,
long
long
*
ll
);
int
REDISMODULE_API_FUNC
(
RedisModule_StringToDouble
)(
RedisModuleString
*
str
,
double
*
d
);
int
REDISMODULE_API_FUNC
(
RedisModule_StringToDouble
)(
const
RedisModuleString
*
str
,
double
*
d
);
void
REDISMODULE_API_FUNC
(
RedisModule_AutoMemory
)(
RedisModuleCtx
*
ctx
);
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_Replicate
)(
RedisModuleCtx
*
ctx
,
const
char
*
cmdname
,
const
char
*
fmt
,
...);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplicateVerbatim
)(
RedisModuleCtx
*
ctx
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplicateVerbatim
)(
RedisModuleCtx
*
ctx
);
...
...
src/server.h
View file @
8f3a4df7
...
@@ -1048,8 +1048,8 @@ struct redisServer {
...
@@ -1048,8 +1048,8 @@ struct redisServer {
long
long
latency_monitor_threshold
;
long
long
latency_monitor_threshold
;
dict
*
latency_events
;
dict
*
latency_events
;
/* Assert & bug reporting */
/* Assert & bug reporting */
char
*
assert_failed
;
const
char
*
assert_failed
;
char
*
assert_file
;
const
char
*
assert_file
;
int
assert_line
;
int
assert_line
;
int
bug_report_start
;
/* True if bug report header was already logged. */
int
bug_report_start
;
/* True if bug report header was already logged. */
int
watchdog_period
;
/* Software watchdog period in ms. 0 = off */
int
watchdog_period
;
/* Software watchdog period in ms. 0 = off */
...
@@ -1245,7 +1245,7 @@ void addReplyStatusFormat(client *c, const char *fmt, ...);
...
@@ -1245,7 +1245,7 @@ void addReplyStatusFormat(client *c, const char *fmt, ...);
void
listTypeTryConversion
(
robj
*
subject
,
robj
*
value
);
void
listTypeTryConversion
(
robj
*
subject
,
robj
*
value
);
void
listTypePush
(
robj
*
subject
,
robj
*
value
,
int
where
);
void
listTypePush
(
robj
*
subject
,
robj
*
value
,
int
where
);
robj
*
listTypePop
(
robj
*
subject
,
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
);
listTypeIterator
*
listTypeInitIterator
(
robj
*
subject
,
long
index
,
unsigned
char
direction
);
void
listTypeReleaseIterator
(
listTypeIterator
*
li
);
void
listTypeReleaseIterator
(
listTypeIterator
*
li
);
int
listTypeNext
(
listTypeIterator
*
li
,
listTypeEntry
*
entry
);
int
listTypeNext
(
listTypeIterator
*
li
,
listTypeEntry
*
entry
);
...
@@ -1305,7 +1305,7 @@ int getLongFromObjectOrReply(client *c, robj *o, long *target, const char *msg);
...
@@ -1305,7 +1305,7 @@ int getLongFromObjectOrReply(client *c, robj *o, long *target, const char *msg);
int
checkType
(
client
*
c
,
robj
*
o
,
int
type
);
int
checkType
(
client
*
c
,
robj
*
o
,
int
type
);
int
getLongLongFromObjectOrReply
(
client
*
c
,
robj
*
o
,
long
long
*
target
,
const
char
*
msg
);
int
getLongLongFromObjectOrReply
(
client
*
c
,
robj
*
o
,
long
long
*
target
,
const
char
*
msg
);
int
getDoubleFromObjectOrReply
(
client
*
c
,
robj
*
o
,
double
*
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
getLongLongFromObject
(
robj
*
o
,
long
long
*
target
);
int
getLongDoubleFromObject
(
robj
*
o
,
long
double
*
target
);
int
getLongDoubleFromObject
(
robj
*
o
,
long
double
*
target
);
int
getLongDoubleFromObjectOrReply
(
client
*
c
,
robj
*
o
,
long
double
*
target
,
const
char
*
msg
);
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);
...
@@ -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
);
void
zzlPrev
(
unsigned
char
*
zl
,
unsigned
char
**
eptr
,
unsigned
char
**
sptr
);
unsigned
char
*
zzlFirstInRange
(
unsigned
char
*
zl
,
zrangespec
*
range
);
unsigned
char
*
zzlFirstInRange
(
unsigned
char
*
zl
,
zrangespec
*
range
);
unsigned
char
*
zzlLastInRange
(
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
zsetConvert
(
robj
*
zobj
,
int
encoding
);
void
zsetConvertToZiplistIfNeeded
(
robj
*
zobj
,
size_t
maxelelen
);
void
zsetConvertToZiplistIfNeeded
(
robj
*
zobj
,
size_t
maxelelen
);
int
zsetScore
(
robj
*
zobj
,
sds
member
,
double
*
score
);
int
zsetScore
(
robj
*
zobj
,
sds
member
,
double
*
score
);
...
@@ -1479,7 +1479,7 @@ int setTypeNext(setTypeIterator *si, sds *sdsele, int64_t *llele);
...
@@ -1479,7 +1479,7 @@ int setTypeNext(setTypeIterator *si, sds *sdsele, int64_t *llele);
sds
setTypeNextObject
(
setTypeIterator
*
si
);
sds
setTypeNextObject
(
setTypeIterator
*
si
);
int
setTypeRandomElement
(
robj
*
setobj
,
sds
*
sdsele
,
int64_t
*
llele
);
int
setTypeRandomElement
(
robj
*
setobj
,
sds
*
sdsele
,
int64_t
*
llele
);
unsigned
long
setTypeRandomElements
(
robj
*
set
,
unsigned
long
count
,
robj
*
aux_set
);
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
);
void
setTypeConvert
(
robj
*
subject
,
int
enc
);
/* Hash data type */
/* Hash data type */
...
@@ -1492,7 +1492,7 @@ void hashTypeTryConversion(robj *subject, robj **argv, int start, int end);
...
@@ -1492,7 +1492,7 @@ void hashTypeTryConversion(robj *subject, robj **argv, int start, int end);
void
hashTypeTryObjectEncoding
(
robj
*
subject
,
robj
**
o1
,
robj
**
o2
);
void
hashTypeTryObjectEncoding
(
robj
*
subject
,
robj
**
o1
,
robj
**
o2
);
int
hashTypeExists
(
robj
*
o
,
sds
key
);
int
hashTypeExists
(
robj
*
o
,
sds
key
);
int
hashTypeDelete
(
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
);
hashTypeIterator
*
hashTypeInitIterator
(
robj
*
subject
);
void
hashTypeReleaseIterator
(
hashTypeIterator
*
hi
);
void
hashTypeReleaseIterator
(
hashTypeIterator
*
hi
);
int
hashTypeNext
(
hashTypeIterator
*
hi
);
int
hashTypeNext
(
hashTypeIterator
*
hi
);
...
@@ -1799,11 +1799,11 @@ void *realloc(void *ptr, size_t size) __attribute__ ((deprecated));
...
@@ -1799,11 +1799,11 @@ void *realloc(void *ptr, size_t size) __attribute__ ((deprecated));
#endif
#endif
/* Debugging stuff */
/* Debugging stuff */
void
_serverAssertWithInfo
(
client
*
c
,
robj
*
o
,
char
*
estr
,
char
*
file
,
int
line
);
void
_serverAssertWithInfo
(
const
client
*
c
,
const
robj
*
o
,
const
char
*
estr
,
const
char
*
file
,
int
line
);
void
_serverAssert
(
char
*
estr
,
char
*
file
,
int
line
);
void
_serverAssert
(
const
char
*
estr
,
const
char
*
file
,
int
line
);
void
_serverPanic
(
char
*
msg
,
char
*
file
,
int
line
);
void
_serverPanic
(
const
char
*
msg
,
const
char
*
file
,
int
line
);
void
bugReportStart
(
void
);
void
bugReportStart
(
void
);
void
serverLogObjectDebugInfo
(
robj
*
o
);
void
serverLogObjectDebugInfo
(
const
robj
*
o
);
void
sigsegvHandler
(
int
sig
,
siginfo_t
*
info
,
void
*
secret
);
void
sigsegvHandler
(
int
sig
,
siginfo_t
*
info
,
void
*
secret
);
sds
genRedisInfoString
(
char
*
section
);
sds
genRedisInfoString
(
char
*
section
);
void
enableWatchdog
(
int
period
);
void
enableWatchdog
(
int
period
);
...
...
src/t_hash.c
View file @
8f3a4df7
...
@@ -308,13 +308,13 @@ int hashTypeDelete(robj *o, sds field) {
...
@@ -308,13 +308,13 @@ int hashTypeDelete(robj *o, sds field) {
}
}
/* Return the number of elements in a hash. */
/* Return the number of elements in a hash. */
unsigned
long
hashTypeLength
(
robj
*
o
)
{
unsigned
long
hashTypeLength
(
const
robj
*
o
)
{
unsigned
long
length
=
ULONG_MAX
;
unsigned
long
length
=
ULONG_MAX
;
if
(
o
->
encoding
==
OBJ_ENCODING_ZIPLIST
)
{
if
(
o
->
encoding
==
OBJ_ENCODING_ZIPLIST
)
{
length
=
ziplistLen
(
o
->
ptr
)
/
2
;
length
=
ziplistLen
(
o
->
ptr
)
/
2
;
}
else
if
(
o
->
encoding
==
OBJ_ENCODING_HT
)
{
}
else
if
(
o
->
encoding
==
OBJ_ENCODING_HT
)
{
length
=
dictSize
((
dict
*
)
o
->
ptr
);
length
=
dictSize
((
const
dict
*
)
o
->
ptr
);
}
else
{
}
else
{
serverPanic
(
"Unknown hash encoding"
);
serverPanic
(
"Unknown hash encoding"
);
}
}
...
...
src/t_list.c
View file @
8f3a4df7
...
@@ -71,7 +71,7 @@ robj *listTypePop(robj *subject, int where) {
...
@@ -71,7 +71,7 @@ robj *listTypePop(robj *subject, int where) {
return
value
;
return
value
;
}
}
unsigned
long
listTypeLength
(
robj
*
subject
)
{
unsigned
long
listTypeLength
(
const
robj
*
subject
)
{
if
(
subject
->
encoding
==
OBJ_ENCODING_QUICKLIST
)
{
if
(
subject
->
encoding
==
OBJ_ENCODING_QUICKLIST
)
{
return
quicklistCount
(
subject
->
ptr
);
return
quicklistCount
(
subject
->
ptr
);
}
else
{
}
else
{
...
...
src/t_set.c
View file @
8f3a4df7
...
@@ -219,11 +219,11 @@ int setTypeRandomElement(robj *setobj, sds *sdsele, int64_t *llele) {
...
@@ -219,11 +219,11 @@ int setTypeRandomElement(robj *setobj, sds *sdsele, int64_t *llele) {
return
setobj
->
encoding
;
return
setobj
->
encoding
;
}
}
unsigned
long
setTypeSize
(
robj
*
subject
)
{
unsigned
long
setTypeSize
(
const
robj
*
subject
)
{
if
(
subject
->
encoding
==
OBJ_ENCODING_HT
)
{
if
(
subject
->
encoding
==
OBJ_ENCODING_HT
)
{
return
dictSize
((
dict
*
)
subject
->
ptr
);
return
dictSize
((
const
dict
*
)
subject
->
ptr
);
}
else
if
(
subject
->
encoding
==
OBJ_ENCODING_INTSET
)
{
}
else
if
(
subject
->
encoding
==
OBJ_ENCODING_INTSET
)
{
return
intsetLen
((
intset
*
)
subject
->
ptr
);
return
intsetLen
((
const
intset
*
)
subject
->
ptr
);
}
else
{
}
else
{
serverPanic
(
"Unknown set encoding"
);
serverPanic
(
"Unknown set encoding"
);
}
}
...
...
src/t_zset.c
View file @
8f3a4df7
...
@@ -1100,12 +1100,12 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig
...
@@ -1100,12 +1100,12 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig
* Common sorted set API
* Common sorted set API
*----------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
unsigned
int
zsetLength
(
robj
*
zobj
)
{
unsigned
int
zsetLength
(
const
robj
*
zobj
)
{
int
length
=
-
1
;
int
length
=
-
1
;
if
(
zobj
->
encoding
==
OBJ_ENCODING_ZIPLIST
)
{
if
(
zobj
->
encoding
==
OBJ_ENCODING_ZIPLIST
)
{
length
=
zzlLength
(
zobj
->
ptr
);
length
=
zzlLength
(
zobj
->
ptr
);
}
else
if
(
zobj
->
encoding
==
OBJ_ENCODING_SKIPLIST
)
{
}
else
if
(
zobj
->
encoding
==
OBJ_ENCODING_SKIPLIST
)
{
length
=
((
zset
*
)
zobj
->
ptr
)
->
zsl
->
length
;
length
=
((
const
zset
*
)
zobj
->
ptr
)
->
zsl
->
length
;
}
else
{
}
else
{
serverPanic
(
"Unknown sorted set encoding"
);
serverPanic
(
"Unknown sorted set encoding"
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment