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
921150fc
Commit
921150fc
authored
Apr 03, 2011
by
Pieter Noordhuis
Browse files
Individual reply object functions may be NULL
parent
b4f85484
Changes
1
Show whitespace changes
Inline
Side-by-side
hiredis.c
View file @
921150fc
...
@@ -271,13 +271,16 @@ static int processLineItem(redisReader *r) {
...
@@ -271,13 +271,16 @@ static int processLineItem(redisReader *r) {
int
len
;
int
len
;
if
((
p
=
readLine
(
r
,
&
len
))
!=
NULL
)
{
if
((
p
=
readLine
(
r
,
&
len
))
!=
NULL
)
{
if
(
r
->
fn
)
{
if
(
cur
->
type
==
REDIS_REPLY_INTEGER
)
{
if
(
cur
->
type
==
REDIS_REPLY_INTEGER
)
{
if
(
r
->
fn
&&
r
->
fn
->
createInteger
)
obj
=
r
->
fn
->
createInteger
(
cur
,
readLongLong
(
p
));
obj
=
r
->
fn
->
createInteger
(
cur
,
readLongLong
(
p
));
else
obj
=
(
void
*
)
REDIS_REPLY_INTEGER
;
}
else
{
}
else
{
/* Type will be error or status. */
if
(
r
->
fn
&&
r
->
fn
->
createString
)
obj
=
r
->
fn
->
createString
(
cur
,
p
,
len
);
obj
=
r
->
fn
->
createString
(
cur
,
p
,
len
);
}
else
}
else
{
obj
=
(
void
*
)(
size_t
)(
cur
->
type
);
obj
=
(
void
*
)(
size_t
)(
cur
->
type
);
}
}
...
@@ -306,15 +309,19 @@ static int processBulkItem(redisReader *r) {
...
@@ -306,15 +309,19 @@ static int processBulkItem(redisReader *r) {
if
(
len
<
0
)
{
if
(
len
<
0
)
{
/* The nil object can always be created. */
/* The nil object can always be created. */
obj
=
r
->
fn
?
r
->
fn
->
createNil
(
cur
)
:
if
(
r
->
fn
&&
r
->
fn
->
createNil
)
(
void
*
)
REDIS_REPLY_NIL
;
obj
=
r
->
fn
->
createNil
(
cur
);
else
obj
=
(
void
*
)
REDIS_REPLY_NIL
;
success
=
1
;
success
=
1
;
}
else
{
}
else
{
/* Only continue when the buffer contains the entire bulk item. */
/* Only continue when the buffer contains the entire bulk item. */
bytelen
+=
len
+
2
;
/* include \r\n */
bytelen
+=
len
+
2
;
/* include \r\n */
if
(
r
->
pos
+
bytelen
<=
r
->
len
)
{
if
(
r
->
pos
+
bytelen
<=
r
->
len
)
{
obj
=
r
->
fn
?
r
->
fn
->
createString
(
cur
,
s
+
2
,
len
)
:
if
(
r
->
fn
&&
r
->
fn
->
createString
)
(
void
*
)
REDIS_REPLY_STRING
;
obj
=
r
->
fn
->
createString
(
cur
,
s
+
2
,
len
);
else
obj
=
(
void
*
)
REDIS_REPLY_STRING
;
success
=
1
;
success
=
1
;
}
}
}
}
...
@@ -351,12 +358,16 @@ static int processMultiBulkItem(redisReader *r) {
...
@@ -351,12 +358,16 @@ static int processMultiBulkItem(redisReader *r) {
root
=
(
r
->
ridx
==
0
);
root
=
(
r
->
ridx
==
0
);
if
(
elements
==
-
1
)
{
if
(
elements
==
-
1
)
{
obj
=
r
->
fn
?
r
->
fn
->
createNil
(
cur
)
:
if
(
r
->
fn
&&
r
->
fn
->
createNil
)
(
void
*
)
REDIS_REPLY_NIL
;
obj
=
r
->
fn
->
createNil
(
cur
);
else
obj
=
(
void
*
)
REDIS_REPLY_NIL
;
moveToNextTask
(
r
);
moveToNextTask
(
r
);
}
else
{
}
else
{
obj
=
r
->
fn
?
r
->
fn
->
createArray
(
cur
,
elements
)
:
if
(
r
->
fn
&&
r
->
fn
->
createArray
)
(
void
*
)
REDIS_REPLY_ARRAY
;
obj
=
r
->
fn
->
createArray
(
cur
,
elements
);
else
obj
=
(
void
*
)
REDIS_REPLY_ARRAY
;
/* Modify task stack when there are more than 0 elements. */
/* Modify task stack when there are more than 0 elements. */
if
(
elements
>
0
)
{
if
(
elements
>
0
)
{
...
...
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