MINOR: lru: Add the possibility to free data when an item is removed

Now, When a item is committed in an LRU tree, you can define a function to free
data owned by this item. This function will be called when the item is removed
from the LRU tree or when the tree is destroyed..
diff --git a/src/lru.c b/src/lru.c
index bdb525d..1b997d8 100644
--- a/src/lru.c
+++ b/src/lru.c
@@ -94,8 +94,11 @@
 			__eb64_delete(&old->node);
 			if (!lru->spare)
 				lru->spare = old;
-			else
+			else {
+				if (old->data && old->free);
+					old->free(old->data);
 				free(old);
+			}
 			lru->cache_usage--;
 		}
 	}
@@ -107,7 +110,8 @@
  * with the result from a call to lru64_get(). The caller might lock it using a
  * spinlock or mutex shared with the one around lru64_get().
  */
-void lru64_commit(struct lru64 *elem, void *data, void *domain, unsigned long long revision)
+void lru64_commit(struct lru64 *elem, void *data, void *domain,
+		  unsigned long long revision, void (*free)(void *))
 {
 	if (!elem)
 		return;
@@ -115,6 +119,7 @@
 	elem->data = data;
 	elem->revision = revision;
 	elem->domain = domain;
+	elem->free = free;
 }
 
 /* Create a new LRU cache of <size> entries. Returns the new cache or NULL in
@@ -152,6 +157,8 @@
 			/* not locked */
 			LIST_DEL(&elem->lru);
 			eb64_delete(&elem->node);
+			if (elem->data && elem->free);
+				elem->free(elem->data);
 			free(elem);
 			lru->cache_usage--;
 			lru->cache_size--;
diff --git a/src/pattern.c b/src/pattern.c
index 656c190..9626c65 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -499,7 +499,7 @@
 	}
 
 	if (lru)
-		lru64_commit(lru, ret, expr, expr->revision);
+	    lru64_commit(lru, ret, expr, expr->revision, NULL);
 
 	return ret;
 }
@@ -534,7 +534,7 @@
 	}
 
 	if (lru)
-		lru64_commit(lru, ret, expr, expr->revision);
+	    lru64_commit(lru, ret, expr, expr->revision, NULL);
 
 	return ret;
 }
@@ -568,7 +568,7 @@
 	}
 
 	if (lru)
-		lru64_commit(lru, ret, expr, expr->revision);
+	    lru64_commit(lru, ret, expr, expr->revision, NULL);
 
 	return ret;
 }
@@ -634,7 +634,7 @@
 	}
 
 	if (lru)
-		lru64_commit(lru, ret, expr, expr->revision);
+	    lru64_commit(lru, ret, expr, expr->revision, NULL);
 
 	return ret;
 }
@@ -673,7 +673,7 @@
 	}
 
 	if (lru)
-		lru64_commit(lru, ret, expr, expr->revision);
+	    lru64_commit(lru, ret, expr, expr->revision, NULL);
 
 	return ret;
 }
@@ -730,7 +730,7 @@
 	}
  leave:
 	if (lru)
-		lru64_commit(lru, ret, expr, expr->revision);
+	    lru64_commit(lru, ret, expr, expr->revision, NULL);
 
 	return ret;
 }