aboutsummaryrefslogtreecommitdiff
path: root/nix/libutil/gcrypt-hash.hh
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-01-08 22:06:54 +0100
committerLudovic Courtès <ludo@gnu.org>2014-01-08 22:06:54 +0100
commit2f265602ff23e41f75932aa568fe62e149e3cb9d (patch)
tree3ff7d0b4be81246a4dfd3df414e163d8cbdc4990 /nix/libutil/gcrypt-hash.hh
parentaa6b0d6bf01aba60c6b5524e4422e7a4cebf01e4 (diff)
parent1d6816f98ca1746f0b627a6dee9c0adbbf7533c4 (diff)
downloadguix-2f265602ff23e41f75932aa568fe62e149e3cb9d.tar
guix-2f265602ff23e41f75932aa568fe62e149e3cb9d.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'nix/libutil/gcrypt-hash.hh')
-rw-r--r--nix/libutil/gcrypt-hash.hh17
1 files changed, 14 insertions, 3 deletions
diff --git a/nix/libutil/gcrypt-hash.hh b/nix/libutil/gcrypt-hash.hh
index d93a6eb881..11f061159f 100644
--- a/nix/libutil/gcrypt-hash.hh
+++ b/nix/libutil/gcrypt-hash.hh
@@ -23,17 +23,28 @@
#include <gcrypt.h>
#include <unistd.h>
-extern "C" {
-
struct guix_hash_context
{
+ /* This copy constructor is needed in 'HashSink::currentHash()' where we
+ expect the copy of a 'Ctx' object to yield a truly different context. */
+ guix_hash_context (guix_hash_context &ref)
+ {
+ if (ref.md_handle == NULL)
+ md_handle = NULL;
+ else
+ gcry_md_copy (&md_handle, ref.md_handle);
+ }
+
+ /* Make sure 'md_handle' is always initialized. */
+ guix_hash_context (): md_handle (NULL) { };
+
gcry_md_hd_t md_handle;
};
+extern "C" {
extern void guix_hash_init (struct guix_hash_context *ctx, int algo);
extern void guix_hash_update (struct guix_hash_context *ctx, const void *buffer,
size_t len);
extern void guix_hash_final (void *resbuf, struct guix_hash_context *ctx,
int algo);
-
}