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
hiredis
Commits
3315c098
Commit
3315c098
authored
Aug 18, 2014
by
Hang Su
Committed by
Matt Stancliff
Jan 05, 2015
Browse files
Use stricter function argument types
'const' where we can. Closes #268
parent
865a3683
Changes
2
Hide whitespace changes
Inline
Side-by-side
async.c
View file @
3315c098
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
} while(0);
} while(0);
/* Forward declaration of function in hiredis.c */
/* Forward declaration of function in hiredis.c */
void
__redisAppendCommand
(
redisContext
*
c
,
char
*
cmd
,
size_t
len
);
int
__redisAppendCommand
(
redisContext
*
c
,
const
char
*
cmd
,
size_t
len
);
/* Functions managing dictionary of callbacks for pub/sub. */
/* Functions managing dictionary of callbacks for pub/sub. */
static
unsigned
int
callbackHash
(
const
void
*
key
)
{
static
unsigned
int
callbackHash
(
const
void
*
key
)
{
...
@@ -550,8 +550,8 @@ void redisAsyncHandleWrite(redisAsyncContext *ac) {
...
@@ -550,8 +550,8 @@ void redisAsyncHandleWrite(redisAsyncContext *ac) {
/* Sets a pointer to the first argument and its length starting at p. Returns
/* Sets a pointer to the first argument and its length starting at p. Returns
* the number of bytes to skip to get to the following argument. */
* the number of bytes to skip to get to the following argument. */
static
char
*
nextArgument
(
char
*
start
,
char
**
str
,
size_t
*
len
)
{
static
const
char
*
nextArgument
(
const
char
*
start
,
const
char
**
str
,
size_t
*
len
)
{
char
*
p
=
start
;
const
char
*
p
=
start
;
if
(
p
[
0
]
!=
'$'
)
{
if
(
p
[
0
]
!=
'$'
)
{
p
=
strchr
(
p
,
'$'
);
p
=
strchr
(
p
,
'$'
);
if
(
p
==
NULL
)
return
NULL
;
if
(
p
==
NULL
)
return
NULL
;
...
@@ -567,13 +567,13 @@ static char *nextArgument(char *start, char **str, size_t *len) {
...
@@ -567,13 +567,13 @@ static char *nextArgument(char *start, char **str, size_t *len) {
/* Helper function for the redisAsyncCommand* family of functions. Writes a
/* Helper function for the redisAsyncCommand* family of functions. Writes a
* formatted command to the output buffer and registers the provided callback
* formatted command to the output buffer and registers the provided callback
* function with the context. */
* function with the context. */
static
int
__redisAsyncCommand
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
char
*
cmd
,
size_t
len
)
{
static
int
__redisAsyncCommand
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
const
char
*
cmd
,
size_t
len
)
{
redisContext
*
c
=
&
(
ac
->
c
);
redisContext
*
c
=
&
(
ac
->
c
);
redisCallback
cb
;
redisCallback
cb
;
int
pvariant
,
hasnext
;
int
pvariant
,
hasnext
;
char
*
cstr
,
*
astr
;
const
char
*
cstr
,
*
astr
;
size_t
clen
,
alen
;
size_t
clen
,
alen
;
char
*
p
;
const
char
*
p
;
sds
sname
;
sds
sname
;
int
ret
;
int
ret
;
...
@@ -662,3 +662,8 @@ int redisAsyncCommandArgv(redisAsyncContext *ac, redisCallbackFn *fn, void *priv
...
@@ -662,3 +662,8 @@ int redisAsyncCommandArgv(redisAsyncContext *ac, redisCallbackFn *fn, void *priv
free
(
cmd
);
free
(
cmd
);
return
status
;
return
status
;
}
}
int
redisAsyncFormattedCommand
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
const
char
*
cmd
,
size_t
len
)
{
int
status
=
__redisAsyncCommand
(
ac
,
fn
,
privdata
,
cmd
,
len
);
return
status
;
}
async.h
View file @
3315c098
...
@@ -118,6 +118,7 @@ void redisAsyncHandleWrite(redisAsyncContext *ac);
...
@@ -118,6 +118,7 @@ void redisAsyncHandleWrite(redisAsyncContext *ac);
int
redisvAsyncCommand
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
const
char
*
format
,
va_list
ap
);
int
redisvAsyncCommand
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
const
char
*
format
,
va_list
ap
);
int
redisAsyncCommand
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
const
char
*
format
,
...);
int
redisAsyncCommand
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
const
char
*
format
,
...);
int
redisAsyncCommandArgv
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
int
argc
,
const
char
**
argv
,
const
size_t
*
argvlen
);
int
redisAsyncCommandArgv
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
int
argc
,
const
char
**
argv
,
const
size_t
*
argvlen
);
int
redisAsyncFormattedCommand
(
redisAsyncContext
*
ac
,
redisCallbackFn
*
fn
,
void
*
privdata
,
const
char
*
cmd
,
size_t
len
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
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