---
name: "critbit0_insert"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/critbit0_insert"
---

# critbit0\_insert(3)

insert a string into a critbit tree

## NAME

critbit0\_insert - insert a string into a critbit tree

## SYNTAX

**#include \<libowfat/critbit.h\>**

critbit0\_tree cb = { 0 };

int **critbit0\_insert**(critbit0\_tree\* *cb*,const char\* *str*);

## DESCRIPTION

critbit0\_insert attempts to insert a string into a critbit0 tree. For this it does not insert a copy of the pointer but makes a copy of the whole string. If *str* is already in *cb*, critbit0\_insert returns 1. If *str* is not in *cb*, it is inserted and critbit0\_insert returns 2. If there is a memory allocation failure on the way, critbit0\_insert leaves *cb* alone and returns 0.

## RETURN VALUE

2 if the key was inserted, 1 if it was already in cb, 0 on memory allocation failure.

## SEE ALSO

[critbit0\_contains(3)](/critbit0_contains/3.md)
