feat(hmp): more erroring in ds_hmp_insert
This commit is contained in:
7
ds.c
7
ds.c
@@ -244,11 +244,16 @@ ds_hmp_insert(ds_hmp_t *hmp, char *key, void *data)
|
|||||||
hash_pos = _ds_hmp_gen_hash(key) % hmp->data_len;
|
hash_pos = _ds_hmp_gen_hash(key) % hmp->data_len;
|
||||||
if (!hmp->data[hash_pos]) {
|
if (!hmp->data[hash_pos]) {
|
||||||
hmp->data[hash_pos] = ds_sll_init();
|
hmp->data[hash_pos] = ds_sll_init();
|
||||||
|
if (!hmp->data[hash_pos]) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the ll and put the data into it */
|
/* get the ll and put the data into it */
|
||||||
ll = hmp->data[hash_pos];
|
ll = hmp->data[hash_pos];
|
||||||
ds_sll_insert(ll, kv);
|
if (ds_sll_insert(ll, kv) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user