From fee9cd163c3492e76135f4864b2d42165694fbf4 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 14 Feb 2022 23:40:40 -0800 Subject: [PATCH] ... --- inc/block.h | 1 + inc/file.h | 5 ++++- src/block.c | 1 + src/file.c | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/inc/block.h b/inc/block.h index d3798ba..8a8d649 100644 --- a/inc/block.h +++ b/inc/block.h @@ -10,6 +10,7 @@ #define BLOCK_SIZE 16384 struct block { + size_t index; unsigned char hash[crypto_hash_sha256_BYTES]; struct block *next; }; diff --git a/inc/file.h b/inc/file.h index 2a996a1..dff32c2 100644 --- a/inc/file.h +++ b/inc/file.h @@ -15,8 +15,11 @@ struct file { char *name; char *path; - unsigned char root[crypto_hash_sha256_BYTES]; + + struct block *root; struct block *piece_layers; + struct block *blocks; + uint64_t size; }; diff --git a/src/block.c b/src/block.c index 6870fd2..f388944 100644 --- a/src/block.c +++ b/src/block.c @@ -43,6 +43,7 @@ int block_init(struct block **p) { return -1; } + (*p)->index = 0; memset((*p)->hash,0,crypto_hash_sha256_BYTES); (*p)->next = NULL; diff --git a/src/file.c b/src/file.c index 1e211d2..5d82848 100644 --- a/src/file.c +++ b/src/file.c @@ -189,8 +189,10 @@ int file_init(struct file **p, const char *path) { (*p)->name = strdup(b); - memset((*p)->root,0,crypto_hash_sha256_BYTES); + (*p)->root = NULL; (*p)->piece_layers = NULL; + (*p)->blocks = NULL; + (*p)->size = 0; return 1; -- 2.39.5