File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 11#include "hash_tables.h"
22
33/**
4- * hash_table_get - retrives a value associated with a key
5- * @ht: the hash table.
6- * @key: the key you are looking for
7- * Return: value associated with the element or NULL
4+ * hash_table_get - Retrieve the value associated with a key
5+ * @ht: A pointer to the hash table
6+ * @key: The key to get the value for
7+ *
8+ * Return: If the key cannot be matched - NULL.
9+ * Otherwise - the value associated with key in ht.
810 */
9-
10- char * hasr_table_get (const hash_table_t * ht , const char * key )
11+ char * hash_table_get (const hash_table_t * ht , const char * key )
1112{
13+ hash_node_t * node ;
1214unsigned long int index ;
13- hash_node_t * current ;
1415
1516if (ht == NULL || key == NULL || * key == '\0' )
1617return (NULL );
@@ -19,9 +20,9 @@ char *hasr_table_get(const hash_table_t *ht, const char *key)
1920if (index >= ht -> size )
2021return (NULL );
2122
22- current = ht -> array [index ];
23- while (current && strcmp (current -> key , key ) != 0 )
24- current = current -> next ;
23+ node = ht -> array [index ];
24+ while (node && strcmp (node -> key , key ) != 0 )
25+ node = node -> next ;
2526
26- return ((current == NULL ) ? NULL : current -> value );
27+ return ((node == NULL ) ? NULL : node -> value );
2728}
You can’t perform that action at this time.
0 commit comments