MINOR: stktable: add stktable_deinit function

Adding sktable_deinit() helper function to properly cleanup a sticktable
that was initialized using stktable_init().

(cherry picked from commit e10cf61099a654b5eaf4b92e0e01e315fda6d116)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6ce5cd0376748c527f257d2ec9f8e9b9807ddb39)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3ced632be4d588cb16bdec01b06c211802a2672e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e5e16fd67cfc84382173adbf99bdcbf50b1a85af)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/include/haproxy/stick_table.h b/include/haproxy/stick_table.h
index 5fd8d1e..50f8ae4 100644
--- a/include/haproxy/stick_table.h
+++ b/include/haproxy/stick_table.h
@@ -46,6 +46,7 @@
 int stksess_kill(struct stktable *t, struct stksess *ts, int decrefcount);
 
 int stktable_init(struct stktable *t);
+void stktable_deinit(struct stktable *t);
 int stktable_parse_type(char **args, int *idx, unsigned long *type, size_t *key_size, const char *file, int linenum);
 int parse_stick_table(const char *file, int linenum, char **args,
                       struct stktable *t, char *id, char *nid, struct peers *peers);
diff --git a/src/proxy.c b/src/proxy.c
index 21966c0..40434d0 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -320,8 +320,7 @@
 
 	pool_destroy(p->req_cap_pool);
 	pool_destroy(p->rsp_cap_pool);
-	if (p->table)
-		pool_destroy(p->table->pool);
+	stktable_deinit(p->table);
 
 	HA_RWLOCK_DESTROY(&p->lbprm.lock);
 	HA_RWLOCK_DESTROY(&p->lock);
diff --git a/src/stick_table.c b/src/stick_table.c
index 7f7c7fe..f2d0472 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -675,6 +675,19 @@
 	return 1;
 }
 
+/* Performs stick table cleanup: it's meant to be called after the table
+ * has been initialized ith stktable_init(), else it will lead to undefined
+ * behavior.
+ *
+ * However it does not free the table pointer itself
+ */
+void stktable_deinit(struct stktable *t)
+{
+	if (!t)
+		return;
+	pool_destroy(t->pool);
+}
+
 /*
  * Configuration keywords of known table types
  */