From: José Bollo Date: Fri, 31 Mar 2017 09:55:20 +0000 (+0200) Subject: Allow detection of session closure X-Git-Tag: dab_3.99.1~113 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fapp-framework-binder.git;a=commitdiff_plain;h=20ea5089d0e5526afaa5231f30add7b25b2499bd Allow detection of session closure In some case it can be good to have a function called when the session closes. This is the case when a binding records an item in the context. With this modification the recorded item can be simply NULL. Change-Id: I5e23f00eb2a6e2639fdeea15f9dea79c7df9dfbb Signed-off-by: José Bollo --- diff --git a/src/afb-session.c b/src/afb-session.c index 07092cea..bc1c1c5f 100644 --- a/src/afb-session.c +++ b/src/afb-session.c @@ -98,7 +98,7 @@ static void free_data (struct afb_session *session) session->cookies[idx] = NULL; while (cookie != NULL) { next = cookie->next; - if (cookie->value != NULL && cookie->freecb != NULL) + if (cookie->freecb != NULL) cookie->freecb(cookie->value); free(cookie); cookie = next; @@ -420,7 +420,7 @@ int afb_session_set_cookie(struct afb_session *session, const void *key, void *v cookie = session->cookies[idx]; while(cookie != NULL) { if (cookie->key == key) { - if (cookie->value != NULL && cookie->value != value && cookie->freecb != NULL) + if (cookie->value != value && cookie->freecb) cookie->freecb(cookie->value); cookie->value = value; cookie->freecb = freecb;