diff --git a/opal/class/opal_hash_table.c b/opal/class/opal_hash_table.c index 105983c00b..87d34f17e3 100644 --- a/opal/class/opal_hash_table.c +++ b/opal/class/opal_hash_table.c @@ -795,6 +795,30 @@ opal_hash_table_get_next_key_uint32(opal_hash_table_t * ht, return OPAL_ERROR; } +int /* OPAL_ return code */ +opal_hash_table_get_first_key_ptr(opal_hash_table_t * ht, + void * *key, size_t *key_size, void * *value, + void * *node) +{ + return opal_hash_table_get_next_key_ptr(ht, key, key_size, value, NULL, node); +} + +int /* OPAL_ return code */ +opal_hash_table_get_next_key_ptr(opal_hash_table_t * ht, + void * *key, size_t *key_size, void * *value, + void * in_node, void * *out_node) +{ + opal_hash_element_t * elt; + if (OPAL_SUCCESS == opal_hash_table_get_next_elt(ht, (opal_hash_element_t *) in_node, &elt)) { + *key = (void *)elt->key.ptr.key; + *key_size = elt->key.ptr.key_size; + *value = elt->value; + *out_node = elt; + return OPAL_SUCCESS; + } + return OPAL_ERROR; +} + int /* OPAL_ return code */ opal_hash_table_get_first_key_uint64(opal_hash_table_t * ht, uint64_t *key, void * *value, diff --git a/opal/class/opal_hash_table.h b/opal/class/opal_hash_table.h index 82f3ec8463..ddf29a1b91 100644 --- a/opal/class/opal_hash_table.h +++ b/opal/class/opal_hash_table.h @@ -302,6 +302,44 @@ OPAL_DECLSPEC int opal_hash_table_get_next_key_uint64(opal_hash_table_t *table, void **out_node); +/** + * Get the first ptr bit key from the hash table, which can be used later to + * get the next key + * @param table The hash table pointer (IN) + * @param key The first key (OUT) + * @param key_size The first key size (OUT) + * @param value The value corresponding to this key (OUT) + * @param node The pointer to the hash table internal node which stores + * the key-value pair (this is required for subsequent calls + * to get_next_key) (OUT) + * @return OPAL error code + * + */ + +OPAL_DECLSPEC int opal_hash_table_get_first_key_ptr(opal_hash_table_t *table, void* *key, + size_t *key_size, void **value, void **node); + + +/** + * Get the next ptr bit key from the hash table, knowing the current key + * @param table The hash table pointer (IN) + * @param key The key (OUT) + * @param key_size The key size (OUT) + * @param value The value corresponding to this key (OUT) + * @param in_node The node pointer from previous call to either get_first + or get_next (IN) + * @param out_node The pointer to the hash table internal node which stores + * the key-value pair (this is required for subsequent calls + * to get_next_key) (OUT) + * @return OPAL error code + * + */ + +OPAL_DECLSPEC int opal_hash_table_get_next_key_ptr(opal_hash_table_t *table, void* *key, + size_t *key_size, void **value, + void *in_node, void **out_node); + + OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_proc_table_t);