From 20ea5089d0e5526afaa5231f30add7b25b2499bd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Fri, 31 Mar 2017 11:55:20 +0200 Subject: [PATCH 1/1] Allow detection of session closure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/afb-session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; -- 2.16.6