| 162 | } |
| 163 | |
| 164 | int strset_add(struct strset *set, const char *str) |
| 165 | { |
| 166 | /* |
| 167 | * Cannot use strmap_put() because it'll return NULL in both cases: |
| 168 | * - cannot find str: NULL means "not found" |
| 169 | * - does find str: NULL is the value associated with str |
| 170 | */ |
| 171 | struct strmap_entry *entry = find_strmap_entry(&set->map, str); |
| 172 | |
| 173 | if (entry) |
| 174 | return 0; |
| 175 | |
| 176 | entry = create_entry(&set->map, str, NULL); |
| 177 | hashmap_add(&set->map.map, &entry->ent); |
| 178 | return 1; |
| 179 | } |