struct block *block, *p; \
\
assert(file_init(file_p,filename)==1); \
- memset((*file_p)->root,root_val,crypto_hash_sha256_BYTES); \
+ assert(block_init(&((*file_p)->root))==1); \
+ memset((*file_p)->root->hash,root_val,crypto_hash_sha256_BYTES); \
for(size_t i=0;i<10;i++) { \
assert(block_init(&block)==1); \
memset(block->hash,i,crypto_hash_sha256_BYTES); \
\
- if((*file_p)->piece_layers==NULL) { \
- (*file_p)->piece_layers = block; \
+ if((*file_p)->blocks==NULL) { \
+ (*file_p)->blocks = block; \
} else { \
p->next = block; \
} \
p = block; \
} \
+\
+ (*file_p)->piece_layers = (*file_p)->blocks; \
+ p->next = (*file_p)->root; \
}
/* Parameters:
for(size_t i=0;i<100;i++) {
assert(file_init(&file1,TEST_FILE_1)==1);
+ assert(1==block_init(&(file1->root)));
+ file1->blocks = file1->root;
memset(file1->root,1,crypto_hash_sha256_BYTES);
+
assert(file_init(&file2,TEST_FILE_2)==1);
+ assert(1==block_init(&(file2->root)));
+ file2->blocks = file2->root;
memset(file2->root,2,crypto_hash_sha256_BYTES);
+
assert(file_init(&file3,TEST_FILE_3)==1);
+ assert(1==block_init(&(file3->root)));
+ file3->blocks = file3->root;
memset(file3->root,3,crypto_hash_sha256_BYTES);
+
assert(file_init(&file4,TEST_FILE_4)==1);
+ assert(1==block_init(&(file4->root)));
+ file4->blocks = file4->root;
memset(file4->root,4,crypto_hash_sha256_BYTES);
assert(torrent_init(&torrent,16384)==1);
assert(1==tree_init(&root));
assert(1==file_init(&file,fileA_path));
- memset(file->root,48,crypto_hash_sha256_BYTES);
+ assert(1==block_init(&(file->root)));
+ file->blocks = file->root;
+ memset(file->root->hash,48,crypto_hash_sha256_BYTES);
file->size = 1024;
assert(1==tree_add(root,file->path,file));
assert(1==tree_init(&root));
assert(1==file_init(&file,fileA_path));
- memset(file->root,48,crypto_hash_sha256_BYTES);
+ assert(1==block_init(&(file->root)));
+ file->blocks = file->root;
+ memset(file->root->hash,48,crypto_hash_sha256_BYTES);
file->size = 1024;
assert(1==tree_add(root,file->path,file));
assert(98==tree_bencode_length(root));
assert(1==file_init(&file,fileB_path));
+ assert(1==block_init(&(file->root)));
+ file->blocks = file->root;
memset(file->root,48,crypto_hash_sha256_BYTES);
file->size = 512;