subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Fuhrmann <stefan.fuhrm...@wandisco.com>
Subject Review of sizeof usage
Date Tue, 11 Aug 2015 14:50:51 GMT
Hi all,

The bug that lead to r1694533 prompted me to grep
for all 2500+ uses of sizeof and to review them.

I only found one other real problem and fixed it in
r1694929. However, I noticed an inconsistency in the
way we use sizeof. In my opinion, we should take the
size of the created or processed variable instead of its
type, i.e.

  abc_t *v = apr_pcalloc(pool, sizeof(*v));
  apr_hash_set(hash, key, sizeof(*key), y);
  z = apr_hash_get(hash, key, sizeof(*key));

rather than

  abc_t *v = apr_pcalloc(pool, sizeof(abc_t));
  apr_hash_set(hash, key, sizeof(key_t), y);
  z = apr_hash_get(hash, key, sizeof(key_t));

I found and fixed about 50 occurrences. If nobody
objects, I'll commit them over the weekend.

-- Stefan^2.

Mime
View raw message