svn commit: samba r1892 - branches/SAMBA_4_0/source/lib

Simo Sorce idra at samba.org
Wed Aug 18 18:34:04 GMT 2004


On Wed, 2004-08-18 at 20:25, tridge at samba.org wrote:
> Author: tridge
> Date: 2004-08-18 18:25:02 +0000 (Wed, 18 Aug 2004)
> New Revision: 1892
> 
> WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/&rev=1892&nolog=1
> 
> Log:
> 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. 
> 

> +/*
> +  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;
> +}

Shouldn't we check the pointer was really allocated by talloc ?
something like:

if (tc->magic == TALLOC_MAGIC) {
	return tc->context;
} else {
	return NULL;
}

?

Simo.
-- 
Simo Sorce    -  idra at samba.org
Samba Team    -  http://www.samba.org
Italian Site  -  http://samba.xsec.it



More information about the samba-technical mailing list