Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
421eec9a
Commit
421eec9a
authored
Apr 03, 2011
by
Pieter Noordhuis
Browse files
Lazily destroy protocol reader buffer
parent
921150fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
hiredis.c
View file @
421eec9a
...
...
@@ -520,6 +520,13 @@ void redisReplyReaderFeed(void *reader, const char *buf, size_t len) {
/* Copy the provided buffer. */
if
(
buf
!=
NULL
&&
len
>=
1
)
{
/* Destroy internal buffer when it is empty and is quite large. */
if
(
r
->
len
==
0
&&
sdsavail
(
r
->
buf
)
>
16
*
1024
)
{
sdsfree
(
r
->
buf
);
r
->
buf
=
sdsempty
();
r
->
pos
=
0
;
}
r
->
buf
=
sdscatlen
(
r
->
buf
,
buf
,
len
);
r
->
len
=
sdslen
(
r
->
buf
);
}
...
...
@@ -562,13 +569,6 @@ int redisReplyReaderGetReply(void *reader, void **reply) {
void
*
aux
=
r
->
reply
;
r
->
reply
=
NULL
;
/* Destroy the buffer when it is empty and is quite large. */
if
(
r
->
len
==
0
&&
sdsavail
(
r
->
buf
)
>
16
*
1024
)
{
sdsfree
(
r
->
buf
);
r
->
buf
=
sdsempty
();
r
->
pos
=
0
;
}
/* Check if there actually *is* a reply. */
if
(
r
->
error
!=
NULL
)
{
return
REDIS_ERR
;
...
...
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