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

Re: svn commit: r39635 - in trunk/subversion/bindings/swig: . include python/libsvn_swig_py

From: Stefan Sperling <stsp_at_elego.de>
Date: Thu, 1 Oct 2009 18:20:31 +0100

On Thu, Oct 01, 2009 at 06:17:02PM +0100, Stefan Sperling wrote:
> On Thu, Oct 01, 2009 at 06:11:48PM +0100, Julian Foad wrote:
> > Stefan Sperling wrote:
> > > > + APR_ARRAY_IDX(temp, targlen, void *) = struct_ptr;
> > >
> > > You could use APR_ARRAY_PUSH(temp, void *) = struct_ptr; here.
> > > That would align better with common use of arrays in our code,
> > > PUSH is usually used for writing to the array, IDX for retrieval.
> >
> > No, PUSH is different: it means extend the array by one element and then
> > set that element.
>
> Oh! Right, then I was mistaken. So in this case, PUSH would only be
> appropriate if the array was created with 0 elements initially.

Wait a minute... that cannot be right.
We're creating arrays with more than 0 elements all over the place
and use PUSH to populate them.

Turns out that new elements are only added as-needed:
/**
 * Add a new element to an array (as a first-in, last-out stack)
 * @param arr The array to add an element to.
 * @return Location for the new element in the array.
 * @remark If there are no free spots in the array, then this function will
 * allocate new space for the new element.
 */
APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr);
[...]
#define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push(ary)))

So I guess using PUSH in that loop is fine after all.

Stefan

-- 
printf("Eh???/n");
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2402621
Received on 2009-10-01 19:20:43 CEST

This is an archived mail posted to the Subversion Dev mailing list.