diff options
| author | Nick Rivera <heronr@users.noreply.github.com> | 2020-04-09 20:23:06 -0700 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-09 20:23:06 -0700 | 
| commit | 0184caac9de25258b23156016b3528e9878f1dae (patch) | |
| tree | cbc0aa54634ef08eb6ea28637517dae7cde1fe50 | |
| parent | a5613f3f7fd3a11353561360d40b9e7dcbeffc7f (diff) | |
| download | hiredict-0184caac9de25258b23156016b3528e9878f1dae.tar.xz | |
Provides an optional cleanup callback for async data.
| -rw-r--r-- | async.c | 5 | ||||
| -rw-r--r-- | async.h | 1 | 
2 files changed, 6 insertions, 0 deletions
| @@ -109,6 +109,7 @@ static redisAsyncContext *redisAsyncInitialize(redisContext *c) {      ac->err = 0;      ac->errstr = NULL;      ac->data = NULL; +    ac->dataCleanup = NULL;      ac->ev.data = NULL;      ac->ev.addRead = NULL; @@ -299,6 +300,10 @@ static void __redisAsyncFree(redisAsyncContext *ac) {          }      } +    if (ac->dataCleanup) { +        ac->dataCleanup(ac->data); +    } +      /* Cleanup self */      redisFree(c);  } @@ -70,6 +70,7 @@ typedef struct redisAsyncContext {      /* Not used by hiredis */      void *data; +    void (*dataCleanup)(void *privdata);      /* Event library data and hooks */      struct { | 
