---
name: "mtree_build"
section: "3"
platform: "linux"
package: "liblibrecast-dev"
version: "0.9.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mtree_build"
---

# mtree\_build(3)

build a merkle tree from base data

## NAME

mtree\_build - build a merkle tree from base data

## LIBRARY

Librecast library (*liblibrecast*, *-llibrecast*)

## SYNOPSIS

```
#include <librecast/mtree.h>
```

**int mtree\_build(mtree\_t** *\*tree***, void \* const** *data***, q\_t** *\*q***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

The **mtree\_build** function builds a merkle tree *tree* which was previously initialized with [**mtree\_init**(3)](/mtree_init/3.md) from the base data pointed to by *data*.

If *q* is not NULL, it must point to a queue *q\_t* structure previously initialized with [**q\_init**(3)](/q_init/3.md). This queue will have jobs enqueued to build the tree. This is normally used in conjunction with a threadpool created with [**q\_pool\_create**(3)](/q_pool_create/3.md) with threads all calling [**q\_job\_seek**(3)](/q_job_seek/3.md).

If *q* is NULL, the creation and destruction of a queue and threadpool will be handled automatically.

## RETURN VALUE

**mtree\_init**() returns zero on success. On error, -1 is returned, and *errno* is set to indicate the error.

The **mtree\_free**() function returns no value, and preserves *errno*.

## ERRORS

TODO

## BUGS

No error handling.

## EXAMPLE

TODO

## SEE ALSO

[**mtree\_init**(3)](/mtree_init/3.md), [**mtree\_free**(3)](/mtree_free/3.md), [**q\_init**(3)](/q_init/3.md), [**q\_pool\_create**(3)](/q_pool_create/3.md), [**q\_job\_seek**(3)](/q_job_seek/3.md)
