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

# mtree\_init(3)

initialize and free a merkle tree

## NAME

mtree\_init, mtree\_free - initialize and free a merkle tree

## LIBRARY

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

## SYNOPSIS

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

**int mtree\_init(mtree\_t** *\*tree***, size\_t** *sz***);** **void mtree\_free(mtree\_t** *\*tree***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

The **tree\_init** function initializes the merkle tree structure *tree* with base data size *sz*. sz is the size in bytes of the base file or data which will be used to build the tree by calling [**mtree\_build**(3)](/mtree_build/3.md).

## 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

- **ENOMEM**

  Not enough space/cannot allocate memory (POSIX.1-2001).

## SEE ALSO

[**mdex\_get**(3)](/mdex_get/3.md), [**mdex\_put**(3)](/mdex_put/3.md), [**mdex\_del**(3)](/mdex_del/3.md)
