MapSetOnlyL
Description
Set the value for in_key, replacing any and all existing entries for that key (collapsing multi-valued entries to a single mapping). L-value form takes ownership of both key and value on success when the corresponding copy_init handler is absent.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in,out | Map handle. |
in_key |
in | Addressable key. |
in_value |
in | Addressable value. |
Success
Returns true. All previous entries for in_key have been removed (their values torn down via value_copy_deinit if configured), and exactly one entry mapping in_key to in_value now exists. Map length reflects the net change. When key_copy_init and/or value_copy_init are absent the respective sources have been zeroed; otherwise unchanged.
Failure
Returns false on allocation failure during the entry-write or rehash step. The map and both sources are unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
KvConfig.c:325:
}
MapSetOnlyL(cfg, key, value);
StrDeinit(&key);
StrDeinit(&value);- In
Insert.h:407:
/// TAGS: Map, Set, Insert
///
#define MapSet(m, in_key, in_value) MapSetOnlyL((m), (in_key), (in_value))
///
- In
Insert.h:554:
#define MapMustSetOnlyL(m, in_key, in_value) \
do { \
if (!MapSetOnlyL((m), (in_key), (in_value))) { \
LOG_FATAL("MapMustSetOnlyL failed"); \
} \
Last updated on