NAME

cat_memdbforeach - apply a function to all entries in a cat_memdb.

SYNOPSIS

#include <cat/cat.h>

#include <cat/catutil.h>

int cat_memdbforeach(cat_memdb *db, cat_memdbtraversefunc *fun, void *data);

DESCRIPTION

This function calls the callback fun for each entry in db, supplying data as argument. The cat_memdbtraversefunc is defined as follows:

 typedef int cat_memdbtraversefunc(cat_memdb *db, catdb_data *dbd, void *data);

The function fun will receive a pointer to each entry in the database in the dbd pointer. The value of an entry can be changed but not the key.

Entries can be inserted or deleted during traversal. However, whether or not entries inserted during traversal are to appear during the traversal is undefined.

Recursive traversals are not allowed.

RETURN VALUES

The function returns the return value from cat_membdtraversefunc if successful. If the cat_membdtraversefunc returns a negative value, traversal will be halted.

SEE ALSO

cat, catutil

cat_newmemdb, cat_freememdb, cat_memdbfunc, cat_memdbflags