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

RE: svn commit: rev 1668 - trunk/subversion/libsvn_fs trunk/subversion/libsvn_repos

From: Sander Striker <striker_at_apache.org>
Date: 2002-04-12 09:07:12 CEST

> From: Greg Stein [mailto:gstein@lyra.org]
> Sent: 12 April 2002 00:14

> On Thu, Apr 11, 2002 at 12:48:13PM -0500, striker@tigris.org wrote:
> >...
> > +++ trunk/subversion/libsvn_fs/fs.c Thu Apr 11 12:48:13 2002
> > @@ -401,6 +401,47 @@
> > "creating Berkeley DB environment dir `%s'",
> > fs->path);
> >
> > + /* Write the DB_CONFIG file. */
> > + {
> > + apr_file_t *dbconfig_file = NULL;
> > + apr_size_t written = 0;
> > + const char *dbconfig_file_name = apr_psprintf (fs->pool,
> > + "%s/%s",
> > + path, "DB_CONFIG");
>
> Much simpler to use: apr_pstrintf(fs->pool, "%s/DB_CONFIG", path);
>
> :-)
>
> > + const char *dbconfig_contents =
>
> static const char * const dbconfig_contents =
>
> That will avoid reinitialization on each entry (gee, a cycle! :-). The extra
> const is also to ensure that it is marked as a constant global.
>
> >...
> > + apr_err = apr_file_write_full (dbconfig_file, dbconfig_contents,
> > + strlen (dbconfig_contents), &written);
>
> Since you don't actually need the value of "written", then you can simply
> pass NULL for that parameter.
>
> In most cases, people don't need that value. They just want to write the
> bytes and punt if an error occurs. "Sophisticated" apps might want to know
> how many were written before an error occurred, so the parameter is there.
> The semantics of the function state that it will all be written, or you get
> an error; thus, success means all written.

Ah, I'll try and find some free cycles to clean up this and svn_repos_create
where I copied it from ;)

> Cheers,
> -g

Sander

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Apr 12 09:01:17 2002

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.