r20242?

tridge at samba.org tridge at samba.org
Tue Dec 19 23:41:42 GMT 2006


Alexander,

 > Speaking of allocations... With talloc() if we use some structure passed
 > in to the function as a parent context we don't change it directly but
 > rather modifying talloc's internal structures associated with this
 > pointer. So in this case would it be safe to still mark passed pointer
 > as const?

The internal structure of talloc() pointers should be completely
ignored by anythingoutside the talloc code. So all you should care
about is whether the body of a talloc pointer is modified.

This is the same as malloc. Internally many malloc implementations use
headers which change when you free a different pointer (due to
coalescing). That doesn't matter for the semantics of the malloc data.

 > My thinking is against it -- i.e. you probably shouldn't specify const
 > for arguments-pointers which you intend to use as parent context in the
 > function.

nope, I disagree. All you should think about is if the data itself
will be modified. That's what matters for the optimisations and checks
that the compiler will do outside of the talloc code. The bits inside
the talloc code is not the concern of the people using the API.

Cheers, Tridge


More information about the samba-technical mailing list