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

Re: SVNDIFF1 is ready to merge

From: <kfogel_at_collab.net>
Date: 2005-12-12 04:47:22 CET

Philip Martin <philip@codematters.co.uk> writes:
> Daniel Berlin <dberlin@dberlin.org> writes:
> > On Sun, 2005-12-11 at 23:40 +0000, Philip Martin wrote:
> >> > {
> >> > + char svnver[4] = "SVN\0";
> >>
> >> That's a bit odd, "SVN\0" is five characters, yet svnver is only [4].
> >
> > Errr, no it's not.
> >
> > \0 = NULL :)
>
> I know that, but "SVN\0" has a terminating NULL in addition to the \0.

I'll bet Daniel wanted the source representation to make clear that
the terminating NULL is part of the format, that's why he gave an
explicit size on the array *and* an explicit terminating NULL on the
initialization string.

If you declare a character array with of size N with an initialization
string, an array of exactly N bytes will be allocated even if it means
tossing the terminating NULL from the string rvalue. In other words,
sizeof(svnver) == 4.

Still, a comment might be helpful here...

-Karl

-- 
www.collab.net  <>  CollabNet  |  Distributed Development On Demand
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Dec 12 06:13:36 2005

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