From cf6b3121747f99836fa0a7d6e3e0b7727965d946 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 17 Jul 2014 12:48:51 +0200 Subject: [PATCH] s3:lib/memcache: make use of talloc for memcache_elements Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke (cherry picked from commit 91105d1057c29c5878f50678baeb1bd1a6f1abe3) --- source3/lib/memcache.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source3/lib/memcache.c b/source3/lib/memcache.c index fe38c9d6281..0f0538fa881 100644 --- a/source3/lib/memcache.c +++ b/source3/lib/memcache.c @@ -63,7 +63,7 @@ static int memcache_destructor(struct memcache *cache) { for (e = cache->mru; e != NULL; e = next) { next = e->next; - SAFE_FREE(e); + TALLOC_FREE(e); } return 0; } @@ -206,7 +206,7 @@ static void memcache_delete_element(struct memcache *cache, cache->size -= memcache_element_size(e->keylength, e->valuelength); - SAFE_FREE(e); + TALLOC_FREE(e); } static void memcache_trim(struct memcache *cache) @@ -285,13 +285,12 @@ void memcache_add(struct memcache *cache, enum memcache_number n, element_size = memcache_element_size(key.length, value.length); - - e = (struct memcache_element *)SMB_MALLOC(element_size); - + e = talloc_size(cache, element_size); if (e == NULL) { - DEBUG(0, ("malloc failed\n")); + DEBUG(0, ("talloc failed\n")); return; } + talloc_set_type(e, struct memcache_element); e->n = n; e->keylength = key.length; -- 2.11.4.GIT