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

Re: CVS update: subversion/subversion/libsvn_fs id.c

From: Jim Blandy <jimb_at_zwingli.cygnus.com>
Date: 2001-02-28 15:58:52 CET

By gum, you're right. I had the call to malloc there in id.c
originally, but Greg S. removed it in revision 1.8. apr_palloc must
have changed since then.

Frankly, I don't blame them. The only advantage of malloc over
apr_palloc is that you can free the block, but every piece of code
either:
1) doesn't assume that pool is zero, and thus can't call free, or
2) does assume that pool is zero, and thus might as well call malloc
   directly and avoid confusion.

Ben Collins-Sussman <sussman@newton.ch.collab.net> writes:
> Uhhhhh, nope. apr_pcalloc was segfaulting on both me and Mike
> (fs-test #5). Adding the malloc fixed this.
>
> Maybe it's time to debug apr. :)
>
> Jim Blandy <jimb@zwingli.cygnus.com> writes:
>
> > This is unnecessary. apr_pcalloc behaves this way automatically
> > whenever its pool argument is zero.
> >
> > sussman@tigris.org writes:
> >
> > >
> > > User: sussman
> > > Date: 01/02/27 14:58:08
> > >
> > > Modified: subversion/libsvn_fs id.c
> > > Log:
> > > (svn_fs_parse_id): bugfix: make this func use malloc if no pool is
> > > given, as described in its documentation.
> > >
> > > Revision Changes Path
> > > 1.16 +8 -1 subversion/subversion/libsvn_fs/id.c
> > >
> > > Index: id.c
> > > ===================================================================
> > > RCS file: /cvs/subversion/subversion/libsvn_fs/id.c,v
> > > retrieving revision 1.15
> > > retrieving revision 1.16
> > > diff -u -r1.15 -r1.16
> > > --- id.c 2001/02/12 00:26:14 1.15
> > > +++ id.c 2001/02/27 22:58:08 1.16
> > > @@ -191,7 +191,14 @@
> > >
> > > /* Allocate the ID array. Note that if pool is zero, apr_palloc
> > > just calls malloc, which meets our promised interface. */
> > > - id = apr_palloc (pool, sizeof (*id) * (id_len + 1));
> > > + if (pool)
> > > + id = apr_palloc (pool, sizeof (*id) * (id_len + 1));
> > > + else
> > > + {
> > > + id = malloc (sizeof (*id) * (id_len + 1));
> > > + if (! id)
> > > + abort(); /* couldn't malloc */
> > > + }
> > >
> > > {
> > > int i = 0;
> > >
> > >
> > >
> > >
>
Received on Sat Oct 21 14:36:23 2006

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.