From c3a2584bb485e41d580e4098731984c194602fc8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 18 Aug 2004 18:25:02 +0000 Subject: r1892: this adds talloc_get_context(), which is something I discussed at the team meeting at CIFS04. It allows you to find the talloc context given any pointer allocated with talloc. (This used to be commit 01dc4ed9b4f9390930d3c235cf2ccf9a9028392d) --- source4/lib/talloc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source4/lib/talloc.c b/source4/lib/talloc.c index 421a09e3c6..328a1ce1d1 100644 --- a/source4/lib/talloc.c +++ b/source4/lib/talloc.c @@ -1,7 +1,7 @@ /* Samba Unix SMB/CIFS implementation. Samba temporary memory allocation functions - Copyright (C) Andrew Tridgell 2000 + Copyright (C) Andrew Tridgell 2000-2004 Copyright (C) 2001, 2002 by Martin Pool This program is free software; you can redistribute it and/or modify @@ -152,6 +152,18 @@ static TALLOC_CTX *talloc_init_internal(void) } +/* + return the talloc context given a pointer that has been allocated using + talloc +*/ +TALLOC_CTX *talloc_get_context(void *ptr) +{ + struct talloc_chunk *tc; + tc = ((struct talloc_chunk *)ptr)-1; + + return tc->context; +} + /** Allocate a bit of memory from the specified pool **/ void *talloc(TALLOC_CTX *t, size_t size) { -- cgit