static int htbucket_remove(htbucket *b, void **data, const void *key, int (*cmp)(const void*, const void*, const void*), const void *cmp_arg, void (*free_key)(void*)) { struct htbucket_item *p, *del; if (!b->root) return HT_ERROR; else if (cmp(key, b->root->key, cmp_arg) == 0) { del = b->root; b->root = del->next; *data = del->data; FREE_KEY(del->key); free(del); return HT_OK; } for (p = b->root; p->next; p = p->next) { if (cmp(key, p->next->key, cmp_arg) == 0) { del = p->next; p->next = del->next; *data = del->data; FREE_KEY(del->key); free(del); return HT_OK; } } return HT_ERROR; }
static void ompi_attribute_keyval_destruct(ompi_attribute_keyval_t *keyval) { if (-1 != keyval->key) { /* If the bindings_extra_state pointer is not NULL, free it */ if (NULL != keyval->bindings_extra_state) { free(keyval->bindings_extra_state); } opal_hash_table_remove_value_uint32(keyval_hash, keyval->key); FREE_KEY(keyval->key); } }
static void htbucket_clear(htbucket *b, void (*free_key)(void*), void (*free_data)(void*)) { struct htbucket_item *p, *del; p = b->root; while (p) { del = p; p = p->next; FREE_KEY(del->key); FREE_DATA(del->data); free(del); } }
static void ompi_attribute_keyval_destruct(ompi_attribute_keyval_t *keyval) { /* THIS FUNCTION ASSUMES THAT THE CALLER ALREADY HAS OBTAINED THE keyval_hash_lock MUTEX! Remove the keyval entry from the hash and free the key. */ if (-1 != keyval->key) { /* If the bindings_extra_state pointer is not NULL, free it */ if (NULL != keyval->bindings_extra_state) { free(keyval->bindings_extra_state); } opal_hash_table_remove_value_uint32(keyval_hash, keyval->key); FREE_KEY(keyval->key); } }