diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2018-02-01 02:18:38 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-02 11:28:41 -0800 |
commit | ac73cedff0db06671e2cab871b84b909b71adbd2 (patch) | |
tree | 832a941d3fafe41260ac779b765e2ee611b42b5a /urlmatch.c | |
parent | hash: move SHA-1 macros to hash.h (diff) | |
download | tgif-ac73cedff0db06671e2cab871b84b909b71adbd2.tar.xz |
hash: create union for hash context allocation
In various parts of our code, we want to allocate a structure
representing the internal state of a hash algorithm. The original
implementation of the hash algorithm abstraction assumed we would do
that using heap allocations, and added a context size element to struct
git_hash_algo. However, most of the existing code uses stack
allocations and conversion would needlessly complicate various parts of
the code. Add a union for the purpose of allocating hash contexts on
the stack and a typedef for ease of use. Use this union for defining
the init, update, and final functions to avoid casts. Remove the ctxsz
element for struct git_hash_algo, which is no longer very useful.
This does mean that stack allocations will grow slightly as additional
hash functions are added, but this should not be a significant problem,
since we don't allocate many hash contexts. The improved usability and
benefits from avoiding dynamic allocation outweigh this small downside.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'urlmatch.c')
0 files changed, 0 insertions, 0 deletions