> -----Original Message----- > From: MARTIN PHILIP [mailto:codematt...@ntlworld.com] On Behalf Of > Philip Martin > Sent: vrijdag 25 november 2011 14:18 > To: dev@subversion.apache.org > Cc: s...@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