On Tue, Apr 21, 2009 at 10:26:17PM +0800, Edmund Wong wrote:
> Hi,
>
> For the docstring of typedef struct svn_wc_diff_callbacks4_t
> in include/svn_wc.h, I came across something that I'm
> a bit confused about:
>
> "
> If @a tree_conflicted is non-NULL, set @a *tree_conflicted to true if
> this operation caused a tree conflict, else to false. "
>
> But if it (I assume the first mention of tree_conflicted should
> have a * before it, right) * tree_conflicted is non-NULL, doesn't
> this mean it is true, so why is it necessary to set it to true?
>
> And if it is NULL, is it not by definition, false?
It is important to realise that 'tree-conflicted' is an _output_
parameter. You pass in a pointer, and the function writes something
to the location the pointer points to, giving you back information
you want to know about.
There can only be one return value in C, and in our case the
return value is an svn_error_t * in most cases. So to return
answers to questions like "is this a tree conflicted item?"
we need to use output parameters. You will find this pattern
being used all over the code base.
Obviously, if you pass a NULL pointer, the function won't have
a way to give you the information. So passing NULL is essentially
saying "I don't want to know about this piece of information,
thank you very much".
Stefan
Received on 2009-04-21 17:09:29 CEST