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

Re: svn commit: r1725957 - /subversion/trunk/subversion/svn/merge-cmd.c

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Thu, 21 Jan 2016 17:46:20 +0000

Stefan Sperling <stsp_at_elego.de> writes:

> Not objecting to this change, but I believe we do have a few
> batons on the stack in several places and I don't think this
> is a problem in general.

It's perfectly acceptable to use a stack variable for a baton but it has
to be in the same scope as function call. In this case moving the stack
variable outside the if() block would have been an alternative solution.

> The stack memory will be available until the function returns,
> which in this case is svn_cl__merge() i.e. the main entry point
> to the subcommand.
> The scope shouldn't matter since there's no garbage collection in C.

The scope does matter: the C standard specifies that the lifetime of an
object "extends from entry into the block with which it is associated
until execution of that block ends" [6.2.4]. An optimising compiler is
free to reuse stack slots once out of scope, either for other stack
variables or for stack space to call a function.

Philip Martin
Received on 2016-01-21 18:46:36 CET

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