diff options
author | Jeff King <peff@peff.net> | 2018-02-14 13:05:46 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-14 10:31:09 -0800 |
commit | aef6cf1e5093f3739e39cfdcfb73f3b862cf842c (patch) | |
tree | dc5beb47c21516b41470a762bb718dd5a42b2237 /t/t4018 | |
parent | Prepare for 2.15.2 (diff) | |
download | tgif-aef6cf1e5093f3739e39cfdcfb73f3b862cf842c.tar.xz |
test-hashmap: use ALLOC_ARRAY rather than bare malloc
These two array allocations have several minor flaws:
- they use bare malloc, rather than our error-checking
xmalloc
- they do a bare multiplication to determine the total
size (which in theory can overflow, though in this case
the sizes are all constants)
- they use sizeof(type), but the type in the second one
doesn't match the actual array (though it's "int" versus
"unsigned int", which are guaranteed by C99 to have the
same size)
None of these are likely to be problems in practice, and
this is just a test helper. But since people often look at
test helpers as reference code, we should do our best to
model the recommended techniques.
Switching to ALLOC_ARRAY fixes all three.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4018')
0 files changed, 0 insertions, 0 deletions