MapSetFirstL
Description
Update the value of the first existing entry that matches in_key, or insert a new entry if no match exists. L-value form takes ownership of in_value on success when the value type has no copy_init handler. The key is always treated as an r-value lookup.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in,out | Map handle. |
in_key |
in | Lookup key (treated as r-value). |
in_value |
in | Addressable replacement value. |
Success
Returns true. If an entry for in_key already existed, the first such entry’s value has been replaced with in_value (and the previous value torn down via value_copy_deinit if configured). If no entry existed, a new (key, value) entry is inserted and length grows by one. When value_copy_init is absent the in_value source has been zeroed; otherwise it is unchanged. The in_key source is never zeroed.
Failure
Returns false on allocation failure during a new-entry insert path. Existing entries are unchanged and the source value is untouched.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Insert.h:519:
#define MapMustSetFirstL(m, in_key, in_value) \
do { \
if (!MapSetFirstL((m), (in_key), (in_value))) { \
LOG_FATAL("MapMustSetFirstL failed"); \
} \