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

Re: svn commit: r38202 - trunk/subversion/libsvn_wc

From: Stefan Sperling <stsp_at_elego.de>
Date: Fri, 26 Jun 2009 11:32:23 +0100

On Fri, Jun 26, 2009 at 07:37:25AM +0200, Greg Stein wrote:
> Okee dokey, then. Seems fine, except that you used apr_pcalloc() when
> a palloc would be just fine. You're filling every byte manually, so
> there is no reason to zero it beforehand.

As a general rule, I'd say just always use pcalloc. Everywhere.
Who knows how the code in question will be tweaked in the future?

We've caused enough problems for e.g. TortoiseSVN in the past by
passing objects containing uninitialised but non-NULL pointers
out to callers of our libraries. They have then no way of checking
the pointers for validity and end up dereferencing them, causing
them to segfault. This can happen easily when structures are extended
and the init code isn't updated.

The small overhead of zeroing memory even if it's not necessary
is much less of a problem. Can't the compiler even optimise it
away if it is redundant?

Received on 2009-06-26 12:32:49 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.