[PATCH 1/1] Add talloc_memdup_type

Sam Liddicott sam at liddicott.com
Tue Jul 8 08:00:08 GMT 2008

* Volker Lendecke wrote, On 06/07/08 08:51:
> You might also want to look at the talloc_set_destructor
> macro and the talloc_size function. Using those tricks way
> the talloc_dup might become easier :-)
* simo wrote, On 04/07/08 16:47:
> talloc_memdup is meant to copy just an anonymous region of memory.
> I would call your new function talloc_dup() instead.
> That would make it clear you are duplicating a full talloc context,
> although I guess that may let people wonder if you also should become
> parent (via references) of the original talloc context children or not.
> This would have to be clearly documented.

I've thought hard about both your comments. I certainly didn't intend to
write something as complicated as talloc_dup you describe.
I was merely intended to preserve a type for talloc_get_name stuff, and
not to address anything else talloc-like.

After much thought, what I should have written.

instead of :
#define talloc_memdup_type(t, p, size) _talloc_memdup(t, p, size,

I meant:
#define talloc_memdup_type(t, p, type) _talloc_memdup((t), (p),
sizeof(type), (#type))

to compliment the existing:
#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)

Instead of giving the size, as for talloc_memdup, one gives the type.

Does this satisfy?


More information about the samba-technical mailing list