src/map.c

changeset 1600
a1a728d7ebfd
parent 1587
7156d6699410
child 1604
68b75c091028
equal deleted inserted replaced
1599:aa55109f01d0 1600:a1a728d7ebfd
112 int cx_map_put(CxMap *map, CxHashKey key, void *value) { 112 int cx_map_put(CxMap *map, CxHashKey key, void *value) {
113 return map->cl->put(map, key, value).key == NULL; 113 return map->cl->put(map, key, value).key == NULL;
114 } 114 }
115 115
116 void *cx_map_emplace(CxMap *map, CxHashKey key) { 116 void *cx_map_emplace(CxMap *map, CxHashKey key) {
117 return map->cl->put(map, key, NULL).value; 117 const CxMapEntry entry = map->cl->put(map, key, NULL);
118 if (entry.key == NULL) return NULL;
119 return entry.value;
118 } 120 }
119 121
120 void *cx_map_get(const CxMap *map, CxHashKey key) { 122 void *cx_map_get(const CxMap *map, CxHashKey key) {
121 return map->cl->get(map, key); 123 return map->cl->get(map, key);
122 } 124 }

mercurial