BUG/MINOR: memory: make the thread-local cache allocator set the debugging link

When building with DEBUG_MEMORY_POOLS, an element returned from the
cache would not have its pool link initialized unless it's allocated
using pool_alloc(). This is problematic for buffer allocators which
use pool_alloc_dirty(), as freeing this object will make the code
think it was allocated from another pool. This patch does two things :
  - make __pool_get_from_cache() set the link
  - remove the extra initialization from pool_alloc() since it's always
    done in either __pool_get_first() or __pool_refill_alloc()

This patch is marked MINOR since it only affects code explicitly built
for debugging. No backport is needed.
diff --git a/include/common/memory.h b/include/common/memory.h
index 2301e3a..b854ebb 100644
--- a/include/common/memory.h
+++ b/include/common/memory.h
@@ -180,6 +180,10 @@
 	pool_cache_count--;
 	LIST_DEL(&item->by_pool);
 	LIST_DEL(&item->by_lru);
+#ifdef DEBUG_MEMORY_POOLS
+	/* keep track of where the element was allocated from */
+	*POOL_LINK(pool, item) = (void *)pool;
+#endif
 	return item;
 }
 
@@ -248,12 +252,6 @@
 	void *p;
 
 	p = pool_alloc_dirty(pool);
-#ifdef DEBUG_MEMORY_POOLS
-	if (p) {
-		/* keep track of where the element was allocated from */
-		*POOL_LINK(pool, p) = (void *)pool;
-	}
-#endif
 	if (p && mem_poison_byte >= 0) {
 		memset(p, mem_poison_byte, pool->size);
 	}
@@ -436,14 +434,6 @@
 	void *p;
 
 	p = pool_alloc_dirty(pool);
-#ifdef DEBUG_MEMORY_POOLS
-	if (p) {
-		HA_SPIN_LOCK(POOL_LOCK, &pool->lock);
-		/* keep track of where the element was allocated from */
-		*POOL_LINK(pool, p) = (void *)pool;
-		HA_SPIN_UNLOCK(POOL_LOCK, &pool->lock);
-	}
-#endif
 	if (p && mem_poison_byte >= 0) {
 		memset(p, mem_poison_byte, pool->size);
 	}