MapInsert
Description
Default insert aliases the L-form: store a new (key, value) entry in the map, taking ownership of both in_key and in_value when their respective copy_init handler is absent.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in,out | Map handle. |
in_key |
in | Addressable key. Must match the map’s key type. |
in_value |
in | Addressable value. Must match the map’s value type. |
Success
Returns true; map length grows by one.
Failure
Returns false on allocation failure or policy violation; the map and both sources are unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Insert.h:504:
#define MapMustInsert(m, in_key, in_value) \
do { \
if (!MapInsert((m), (in_key), (in_value))) { \
LOG_FATAL("MapMustInsert failed"); \
} \- In
Insert.c:628:
// MapInsert aliases MapInsertL: both sources zeroed.
MapInsert(&map, k1, v1);
bool result = (k1 == 0) && (v1 == 0);
result = result && (MapValueCountForKey(&map, 1) == 1);
Last updated on