On Sun, Aug 22, 2010 at 01:44:07PM +0200, Stefan Sperling wrote:
> On Sun, Aug 22, 2010 at 11:37:38AM -0000, stefan2_at_apache.org wrote:
> > Author: stefan2
> > Date: Sun Aug 22 11:37:38 2010
> > New Revision: 987869
> >
> > URL: http://svn.apache.org/viewvc?rev=987869&view=rev
> > Log:
> > Fix VisualStudio build: memory size calculation for variable size
> > arrays is not portable.
> >
> > * subversion/libsvn_fs_fs/temp_serializer.c
> > (serialize_dir, serialize_txdelta_ops): fix array size calculation
> >
> > Modified:
> > subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c
> >
> > Modified: subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c
> > URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c?rev=987869&r1=987868&r2=987869&view=diff
> > ==============================================================================
> > --- subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c (original)
> > +++ subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c Sun Aug 22 11:37:38 2010
> > @@ -272,7 +272,7 @@ serialize_dir(apr_hash_t *entries, apr_p
> >
> > /* calculate sizes */
> > apr_size_t count = apr_hash_count(entries);
> > - apr_size_t entries_len = sizeof(svn_fs_dirent_t*[count]);
> > + apr_size_t entries_len = count * sizeof(svn_fs_dirent_t*[1]);
>
> Do you really want the second asterisk in that line?
> It looks like you really want this:
>
> + apr_size_t entries_len = count * sizeof(svn_fs_dirent_t[1]);
Bah, what I wrote doesn't make any sense.
Let me try again:
I don't understand that syntax.
Is this really treating a pointer to a struct as an array with a single
element? If so, why?
It looks like this is saying "I need 'count' times the size of
a pointer to svn_fs_dirent_t". So why not just write:
apr_size_t entries_len = count * sizeof(svn_fs_dirent_t*);
>
> >
> > /* copy the hash entries to an auxilliary struct of known layout */
> > hash_data.count = count;
> > @@ -422,7 +422,7 @@ serialize_txdelta_ops(svn_temp_serialize
> > /* the ops form a simple chunk of memory with no further references */
> > svn_temp_serializer__push(context,
> > (const void * const *)ops,
> > - sizeof(svn_txdelta_op_t[count]));
> > + count * sizeof(svn_txdelta_op_t[1]));
Again, the [1] seems redundant. What's it for?
Thanks,
Stefan
Received on 2010-08-22 13:55:24 CEST