Unverified Commit 0184caac authored by Nick Rivera's avatar Nick Rivera Committed by GitHub
Browse files

Provides an optional cleanup callback for async data.

parent a5613f3f
...@@ -109,6 +109,7 @@ static redisAsyncContext *redisAsyncInitialize(redisContext *c) { ...@@ -109,6 +109,7 @@ static redisAsyncContext *redisAsyncInitialize(redisContext *c) {
ac->err = 0; ac->err = 0;
ac->errstr = NULL; ac->errstr = NULL;
ac->data = NULL; ac->data = NULL;
ac->dataCleanup = NULL;
ac->ev.data = NULL; ac->ev.data = NULL;
ac->ev.addRead = NULL; ac->ev.addRead = NULL;
...@@ -299,6 +300,10 @@ static void __redisAsyncFree(redisAsyncContext *ac) { ...@@ -299,6 +300,10 @@ static void __redisAsyncFree(redisAsyncContext *ac) {
} }
} }
if (ac->dataCleanup) {
ac->dataCleanup(ac->data);
}
/* Cleanup self */ /* Cleanup self */
redisFree(c); redisFree(c);
} }
......
...@@ -70,6 +70,7 @@ typedef struct redisAsyncContext { ...@@ -70,6 +70,7 @@ typedef struct redisAsyncContext {
/* Not used by hiredis */ /* Not used by hiredis */
void *data; void *data;
void (*dataCleanup)(void *privdata);
/* Event library data and hooks */ /* Event library data and hooks */
struct { struct {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment