]> git.ipfire.org Git - thirdparty/ccache.git/commit
Improve how <MD4, number of hashed bytes> is represented
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 8 Jun 2019 11:25:49 +0000 (13:25 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 8 Jun 2019 19:17:48 +0000 (21:17 +0200)
commit10bce6078e74c19dfea9f19d15daff5ca7ab2a2c
treecda5b6ca9eca8f4a77fc2bfd4fe251e56f08ed02
parent2b568ba6ba93cec78e478fb63f5353975055539b
Improve how <MD4, number of hashed bytes> is represented

Internally, the tuple <MD4 hash, number of hashed bytes>,which is the
key used for cached results and manifests, was represented as 16 bytes +
1 uint32_t. Externally, i.e. in file names, it was represented as
<MD4>-<size>, with <MD4> being 32 hex digits and <size> being the number
of hashed bytes in human-readable form.

This commits changes the internal representation to 20 bytes, where the
last 4 bytes are the number of hashed bytes in big-endian order. The
external representation has been changed to match this, i.e. to be 40
hex digits. This makes the code slightly less complex and more
consistent. Also, the code that converts the key into string form has
been rewritten to not allocate on the heap but to just write the output
into a buffer owned by the caller.

struct file_hash (16 bytes + 1 uint32_t) has been renamed to struct
digest (20 bytes) in order to emphasize that it represents the output of
a hash algorithm that not necessarily gets file content as its input.

The documentation of the manifest format has been updated to reflect the
logical change of keys, even though the actual serialized content of
manifest files hasn’t changed. While at it, reading of the obsolete
“hash_size” and “reserved” fields has been removed. (Future changes in
the manifest format will be handled by just stepping the version.)
17 files changed:
configure.ac
doc/MANUAL.adoc
src/ccache.c
src/ccache.h
src/hash.c
src/hash.h
src/hashutil.c
src/hashutil.h
src/manifest.c
src/manifest.h
src/util.c
test/suites/base.bash
test/suites/direct.bash
unittest/framework.c
unittest/test_hash.c
unittest/test_hashutil.c
unittest/test_util.c