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

RE: scan-log-moves hash structure

From: Bert Huijben <bert_at_qqmail.nl>
Date: Fri, 25 Nov 2011 14:29:10 +0100

> -----Original Message-----
> From: MARTIN PHILIP [mailto:codematters_at_ntlworld.com] On Behalf Of
> Philip Martin
> Sent: vrijdag 25 november 2011 14:18
> To: dev_at_subversion.apache.org
> Cc: stsp_at_elego.de
> Subject: scan-log-moves hash structure
>
> scan_moves_log_receiver does:
>
> moves = apr_hash_get(b->moves, &new_move->revision,
> sizeof(svn_revnum_t));
> if (moves == NULL)
> {
> moves = apr_array_make(result_pool, 1,
> sizeof(svn_wc_repos_move_info_t *));
> APR_ARRAY_PUSH(moves, svn_wc_repos_move_info_t *) =
> new_move;
> apr_hash_set(b->moves, &new_move->revision,
> sizeof(svn_revnum_t),
> moves);
> }
> else
> APR_ARRAY_PUSH(moves, svn_wc_repos_move_info_t *) =
> new_move;
>
>
> The hash get and set are using the *address* of the revnum, not the
> revnum itself. That doesn't look right to me, I think it should be
> using the revnum. If it is right then the sizeofs are wrong.

I think this is exactly the same thing as when using strings: You pass the
address of the characters and the length of the string (without the final \0
if I remember correctly).

You can't just push a revnum casted to a pointer as the key. (You could do
that as value though).

One thing to verify is that the void * key (pointing to the svn_revnum_t) of
must have a similar lifetime as the hashtable, which this snippet does.

        Bert
Received on 2011-11-25 14:29:49 CET

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.