---
name: "rbhash_insert"
section: "3"
platform: "linux"
package: "libroy-dev"
version: "1.0.8-1"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/rbhash_insert"
---

# rbhash\_insert(3)

insert a new entry into an rbhash

## NAME

rbhash\_insert - insert a new entry into an rbhash

## SYNOPSIS

\#include \<roy.h\>

void rbhash\_insert (RBHash *\*hash*, void \**entry*, RBuf \**key*);

## DESCRIPTION

Inserts a new entry into a hash table.  The entry structure is defined by the user, and should contain the macro 'RBHASH\_HEADER'.  See [*rbhash*(3)](/rbhash/3.md) for information on how to create a compatible RBHashEntry structure.

This function sets *key* as the key for *entry*; the equivalent of calling [*rbhash\_entry\_setkey*(3)](/rbhash_entry_setkey/3.md).  The key is stored using an RBuf \* pointer within the RBHASH\_HEADER; no copy of the RBuf itself is made.

## RETURN VALUE

This function doesn't reutrn a value.

## DUPLICATE ENTRIES

If an entry is inserted into the hash table with a key of an entry that already exists in the hash table, they will both be added and no error condition will exist.  Any calls thereafter to [*rbhash\_lookup*(3)](/rbhash_lookup/3.md) will return the first entry inserted with that key.

If you do not wish to have multiple entries with the same key, you must do a [*rbhash\_lookup*(3)](/rbhash_lookup/3.md) prior to inserting the new entry.

## SEE ALSO

[*rbhash*(3)](/rbhash/3.md), [*rbhash\_entry\_getkey*(3)](/rbhash_entry_getkey/3.md),  [*rbhash\_entry\_setkey*(3)](/rbhash_entry_setkey/3.md), [*rbhash\_free*(3)](/rbhash_free/3.md),  [*rbhash\_len*(3)](/rbhash_len/3.md), [*rbhash\_lookup*(3)](/rbhash_lookup/3.md),  [*rbhash\_lookup\_next*(3)](/rbhash_lookup_next/3.md), [*rbhash\_new*(3)](/rbhash_new/3.md),  [*rbhash\_remove*(3)](/rbhash_remove/3.md), [*rbhash\_remove\_entry*(3)](/rbhash_remove_entry/3.md),  [*roy*(3)](/roy/3.md)
