bug 116546

Linas Vepstas linas at linas.org
Tue Jul 29 12:49:14 CDT 2003


On Sun, Jul 27, 2003 at 01:54:58PM -0500, Matthew Vanecek was heard to remark:
> > 
> > +      for (node = be->blist; node; node = node->next) {
> > +          g_free(node->data);
> > +          node->data = NULL;
> > +      }

As a general and simplistic rule, if you didn't alloc it, don't free it.
If you called xaccXXXMalloc, then call xaccXXXFree, but otherwise, 
you shouldn't touch it.

> > +   if (1 < be->nest_count) {
> > +       LEAVE("be->nest_count < 1: %d", be->nest_count); 
> > 
> > The message is reversed.  This is checking whether be->next_count > 1
> > 
> > (FWIW, I absolutely despise this style, for this exact reason!)

I love this style.  Its saved my but several times when I types
be->next_count  = 1
instead of
be->next_count  == 1

I admit it contrary to the norm, but its not hard to get used to, 
and after a while, you wonder why everybody doesn't use it.

(Its part of my philosphy that one-byte typing errors should 
cause compiler faults  instead of silent, hard-to-find bugs.

Although I'm still ambivalent about 
if (NULL == xx) 
vs.
if (!x)
since I'm also a lazy typist.)

--linas


-- 
pub  1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas at linas.org>
PGP Key fingerprint = 8305 2521 6000 0B5E 8984  3F54 64A9 9A82 0104 5933


More information about the gnucash-devel mailing list