---
name: "cmap_iter_init"
section: "3"
platform: "linux"
package: "libcmap-dev"
version: "3.1.9-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/cmap_iter_init"
---

# cmap\_iter\_init(3)

Initialize iterator for keys stored in CMAP

## NAME

cmap\_iter\_init - Initialize iterator for keys stored in CMAP

## SYNOPSIS

**#include \<corosync/cmap.h\>**

**cs\_error\_t** **cmap\_iter\_init (cmap\_handle\_t** *handle***, const char \****prefix***, cmap\_iter\_handle\_t \****cmap\_iter\_handle***);**

## DESCRIPTION

The **cmap\_iter\_init** function is used to initialize iteration of all keys with given *prefix.* The *handle* argument is connection to CMAP database obtained by calling **[cmap\_initialize(3)](/cmap_initialize/3.md)** function. *prefix* is string, and every returned key must have name with given prefix. This variable can also be NULL (or empty string) and then all keys are iterated.

**cmap\_iter\_init** is used only for initialize context for future **[cmap\_iter\_next(3)](/cmap_iter_next/3.md)** calls and handle needed for that function is returned in *cmap\_iter\_handle* variable. When you have finished iteration over objects, call **[cmap\_iter\_finalize(3)](/cmap_iter_finalize/3.md)** function to free up memory associated with iteration.

## RETURN VALUE

This call returns the CS\_OK value if successful. If there are no items with given prefixes, CS\_ERR\_NO\_SECTIONS is returned.

## SEE ALSO

[**cmap\_iter\_next**(3)](/cmap_iter_next/3.md), [**cmap\_iter\_finalize**(3)](/cmap_iter_finalize/3.md), [**cmap\_initialize**(3)](/cmap_initialize/3.md), [**cmap\_overview**(3)](/cmap_overview/3.md)

**CS\_ERR\_TRY\_AGAIN** Resource temporarily unavailable

**CS\_ERR\_INVALID\_PARAM** Invalid argument

**CS\_ERR\_ACCESS** Permission denied

**CS\_ERR\_LIBRARY** The connection failed

**CS\_ERR\_INTERRUPT** System call interrupted by a signal

**CS\_ERR\_NOT\_SUPPORTED** The requested protocol/functionality not supported

**CS\_ERR\_MESSAGE\_ERROR** Incorrect auth message received

**CS\_ERR\_NO\_MEMORY** Not enough memory to complete the requested task
