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
3d702d0b
Commit
3d702d0b
authored
Nov 24, 2010
by
Pieter Noordhuis
Browse files
Don't care if object returned by object function is NULL
parent
1927c643
Changes
1
Hide whitespace changes
Inline
Side-by-side
hiredis.c
View file @
3d702d0b
...
...
@@ -236,9 +236,8 @@ static int processLineItem(redisReader *r) {
obj
=
(
void
*
)(
size_t
)(
cur
->
type
);
}
/* If there is no root yet, register this object as root. */
if
(
r
->
reply
==
NULL
)
r
->
reply
=
obj
;
/* Set reply if this is the root object. */
if
(
r
->
ridx
==
0
)
r
->
reply
=
obj
;
moveToNextTask
(
r
);
return
0
;
}
...
...
@@ -251,6 +250,7 @@ static int processBulkItem(redisReader *r) {
char
*
p
,
*
s
;
long
len
;
unsigned
long
bytelen
;
int
success
=
0
;
p
=
r
->
buf
+
r
->
pos
;
s
=
seekNewline
(
p
);
...
...
@@ -263,20 +263,23 @@ static int processBulkItem(redisReader *r) {
/* The nil object can always be created. */
obj
=
r
->
fn
?
r
->
fn
->
createNil
(
cur
)
:
(
void
*
)
REDIS_REPLY_NIL
;
success
=
1
;
}
else
{
/* Only continue when the buffer contains the entire bulk item. */
bytelen
+=
len
+
2
;
/* include \r\n */
if
(
r
->
pos
+
bytelen
<=
sdslen
(
r
->
buf
))
{
obj
=
r
->
fn
?
r
->
fn
->
createString
(
cur
,
s
+
2
,
len
)
:
(
void
*
)
REDIS_REPLY_STRING
;
success
=
1
;
}
}
/* Proceed when obj was created. */
if
(
obj
!=
NULL
)
{
if
(
success
)
{
r
->
pos
+=
bytelen
;
if
(
r
->
reply
==
NULL
)
r
->
reply
=
obj
;
/* Set reply if this is the root object. */
if
(
r
->
ridx
==
0
)
r
->
reply
=
obj
;
moveToNextTask
(
r
);
return
0
;
}
...
...
@@ -289,9 +292,12 @@ static int processMultiBulkItem(redisReader *r) {
void
*
obj
;
char
*
p
;
long
elements
;
int
root
=
0
;
if
((
p
=
readLine
(
r
,
NULL
))
!=
NULL
)
{
elements
=
strtol
(
p
,
NULL
,
10
);
root
=
(
r
->
ridx
==
0
);
if
(
elements
==
-
1
)
{
obj
=
r
->
fn
?
r
->
fn
->
createNil
(
cur
)
:
(
void
*
)
REDIS_REPLY_NIL
;
...
...
@@ -314,9 +320,8 @@ static int processMultiBulkItem(redisReader *r) {
}
}
/* Object was created, so we can always continue. */
if
(
r
->
reply
==
NULL
)
r
->
reply
=
obj
;
/* Set reply if this is the root object. */
if
(
root
)
r
->
reply
=
obj
;
return
0
;
}
return
-
1
;
...
...
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