r20242?

Alexander Bokovoy ab at samba.org
Wed Dec 20 07:07:20 GMT 2006


tridge at samba.org wrote:
> Alexander,
> 
>> This is not what I'm talking about. If hierarhy is used within 
>> application then allocating something in a context is effectifely 
>> changing that hierarchy, hence changing user data (of which this 
>> hierarchy is a part).
> 
> no. The hierarchy is _not_ part of the user data. It's magic. It is 
> not in the bytes accessible from the pointers returned by talloc.
Of course it is not in the bytes, it is in the design of application.
I'm not trying to convince that hierarchy is accessible in the sequence
of bytes pointed to by the talloc()-ed structure. Rather, I'm pointing
to the fact that allocating anything on that context _is_ changing an
associated hierarchy and therefore, changing user data as a whole by
spirit, if you'd accept such a comparison. Here user data is both the
structure and the context in which it exists for cases when application
is relying on hierarchy built by talloc.

Therefore, marking context as const would be a sign that function is not
producing side effects on the context (as a whole) rather than on the
passed structure only. Sort of 'contract' between an API provider and
API consumer. In this case const serves more than just means to help
compiler track undesired changes to data. Unfortunately, C language
translators don't have means for tracking such concepts properly and
using const is one of (weaker) ways to help here.

-- 
/ Alexander Bokovoy
Samba Team                      http://www.samba.org/
ALT Linux Team                  http://www.altlinux.org/
Midgard Project Ry              http://www.midgard-project.org/


More information about the samba-technical mailing list