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

Re: svn commit: r32524 - in trunk: . subversion/include subversion/libsvn_subr subversion/tests/libsvn_subr

From: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: Mon, 18 Aug 2008 15:20:53 -0700

> -------Original Message-------
> From: Greg Stein <gstein_at_gmail.com>
> Subject: Re: svn commit: r32524 - in trunk: . subversion/include subversion/libsvn_subr subversion/tests/libsvn_subr
> Sent: 18 Aug '08 13:55
>
> On Mon, Aug 18, 2008 at 9:47 AM,  <hwright_at_tigris.org> wrote:
> >...
> > +++ trunk/subversion/libsvn_subr/checksum.c     Mon Aug 18 09:47:20 2008        (r32524)
> >...
> > +svn_checksum_create(svn_checksum_kind_t kind,
> >                     apr_pool_t *pool)
> >  {
> > -  *checksum = apr_palloc(pool, sizeof(*checksum));
> > +  svn_checksum_t *checksum = apr_palloc(pool, sizeof(*checksum));
>
> I think you could reduce this to one allocation:
>
> svn_checksum_t *checksum = apr_palloc(pool, sizeof(*checksum) +
> APR_MD5_DIGESTSIZE);
> checksum->digest = (unsigned char *)checksum + APR_MD5_DIGESTSIZE;
>
> Put that into each block of the switch.
>
> Also, shouldn't the digest be zero'd out? (if so, then use apr_pcalloc)

Good point, done in r32530.

> >...
> > +svn_checksum_clear(svn_checksum_t *checksum)
> > +{
> > +  switch (checksum->kind)
> > +    {
> > +      case svn_checksum_md5:
> > +        memset(checksum->digest, 0, APR_MD5_DIGESTSIZE);
> > +        break;
> > +
> > +      case svn_checksum_sha1:
> > +        memset(checksum->digest, 0, APR_SHA1_DIGESTSIZE);
>
> Might be handy to have a macro that returns the digest size given the
> kind. It could be used in numerous places, I think.
>
> #define whatever(kind) (kind == svn_checksum_md5 ? APR_MD5_DIGESTSIZE
> : (kind == svn_checksum_sha1 ? APR_SHA1_DIGESTSIZE : 0))

Yeah, I've defined that, as well as a "kind validator" function. Hopefully that's cleaned things up a bit.

> >...
> > +  baton->read_more = read_all;
>
> Why the change in name?

I'm confused. I didn't change anything here, this is just a carry over from svn_stream_checksummed(). It came across as modified because of it's placement in the diff, but looking at r31972 of svn_stream_checksummed(), it contains the same line.

-Hyrum

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-08-19 00:21:04 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.