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
09a0fe62
Commit
09a0fe62
authored
Nov 15, 2010
by
Pieter Noordhuis
Browse files
Explicitly initialize struct fields to NULL
parent
0b27639e
Changes
2
Hide whitespace changes
Inline
Side-by-side
async.c
View file @
09a0fe62
...
...
@@ -38,8 +38,17 @@ void __redisAppendCommand(redisContext *c, char *cmd, size_t len);
static
redisAsyncContext
*
redisAsyncInitialize
(
redisContext
*
c
)
{
redisAsyncContext
*
ac
=
realloc
(
c
,
sizeof
(
redisAsyncContext
));
/* Set all bytes in the async part of the context to 0 */
memset
(
ac
+
sizeof
(
redisContext
),
0
,
sizeof
(
redisAsyncContext
)
-
sizeof
(
redisContext
));
ac
->
err
=
0
;
ac
->
errstr
=
NULL
;
ac
->
data
=
NULL
;
ac
->
evAddRead
=
NULL
;
ac
->
evDelRead
=
NULL
;
ac
->
evAddWrite
=
NULL
;
ac
->
evDelWrite
=
NULL
;
ac
->
evCleanup
=
NULL
;
ac
->
onDisconnect
=
NULL
;
ac
->
replies
.
head
=
NULL
;
ac
->
replies
.
tail
=
NULL
;
return
ac
;
}
...
...
async.h
View file @
09a0fe62
...
...
@@ -58,6 +58,9 @@ typedef struct redisAsyncContext {
int
err
;
char
*
errstr
;
/* Not used by hiredis */
void
*
data
;
/* Called when the library expects to start reading/writing.
* The supplied functions should be idempotent. */
void
(
*
evAddRead
)(
void
*
privdata
);
...
...
@@ -65,7 +68,6 @@ typedef struct redisAsyncContext {
void
(
*
evAddWrite
)(
void
*
privdata
);
void
(
*
evDelWrite
)(
void
*
privdata
);
void
(
*
evCleanup
)(
void
*
privdata
);
void
*
data
;
/* Called when either the connection is terminated due to an error or per
* user request. The status is set accordingly (REDIS_OK, 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