| 66 | } |
| 67 | |
| 68 | void *cbm_ht_set(CBMHashTable *ht, const char *key, void *value) { |
| 69 | if (!ht || !key) |
| 70 | return NULL; |
| 71 | /* Capture previous value (if any) before overwriting. |
| 72 | * Verstable's _insert overwrites silently and returns an iterator |
| 73 | * to the (now updated) entry — we have to peek first to surface |
| 74 | * the prior value to the caller (back-compat with our API). */ |
| 75 | void *prev = NULL; |
| 76 | cbm_vt_itr itr = cbm_vt_get(&ht->vt, key); |
| 77 | if (!cbm_vt_is_end(itr)) { |
| 78 | prev = itr.data->val; |
| 79 | } |
| 80 | (void)cbm_vt_insert(&ht->vt, key, value); |
| 81 | return prev; |
| 82 | } |
| 83 | |
| 84 | void *cbm_ht_get(const CBMHashTable *ht, const char *key) { |
| 85 | if (!ht || !key) |
no outgoing calls
no test coverage detected