File: mtree_diff_subtree.3

package info (click to toggle)
librecast 0.11.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,760 kB
  • sloc: ansic: 31,144; asm: 28,570; sh: 3,164; makefile: 713; python: 70
file content (59 lines) | stat: -rw-r--r-- 1,698 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.TH MTREE_DIFF_SUBTREE 3 2023-06-20 "LIBRECAST" "Librecast Programmer's Manual"
.SH NAME
mtree_diff_subtree \- compare two subtrees and return bitmap
.SH LIBRARY
Librecast library
.RI ( liblibrecast ", " \-llibrecast )
.SH SYNOPSIS
.nf
.B #include <librecast/mtree.h>
.PP
.BI "unsigned char *mtree_diff_subtree(mtree_t " *t1 ", mtree_t " *t2 ", size_t " root ", unsigned " bits ");"
.BI "unsigned char *mtree_diff_map(mtree_t " *t1 ", mtree_t " *t2 ");"
.fi
.PP
Compile and link with \fI\-llibrecast\fP.
.SH DESCRIPTION
The
.BR mtree_diff_subtree
function performs a bredth-first comparison of the merkle trees
.IR t1
and
.IR t2
and returns a pointer to a bitmap, setting
.IR bits
bits for any chunks that differ.
.IR bits
should be set to the number of packets required to to transport each chunk. When bits > 1, chunks will be fragmented into multiple packets, and the bitmap will represent the packets required.
.PP
Checking the popcount (Hamming Weight) of the returned bitmap gives the number of packets required to patch the differences.
.PP
The returned bitmap must be freed by the caller when no longer needed by passing to
.BR free (3).
.PP
.BR mtree_diff_map ()
is a convenience wrapper that is the same as calling
.BR mtree_diff_subtree ()
with
.IR root
set to zero (whole tree)
and
.IR bits
set to one. Thus, it returns a bitmap of the entire tree with a single bit per
chunk.
.PP
.SH RETURN VALUE
.BR mtree_verify ()
returns zero if the tree is valid, or NULL on error, with
.IR errno
set to indicate the error.
.SH ERRORS
.TP
.BR ENOMEM
Not enough space/cannot allocate memory (POSIX.1-2001).
.PP
.SH SEE ALSO
.BR mtree_init (3),
.BR mtree_free (3),
.BR mtree_build (3),
.BR free (3)