[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: docstring query

From: Stefan Sperling <stsp_at_elego.de>
Date: Tue, 21 Apr 2009 16:08:57 +0100

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

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.