Skip to content

Commit 789b758

Browse files
committed
task 4 correction
1 parent 87d5aa2 commit 789b758

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
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;
1214
unsigned long int index;
13-
hash_node_t *current;
1415

1516
if (ht == NULL || key == NULL || *key == '\0')
1617
return (NULL);
@@ -19,9 +20,9 @@ char *hasr_table_get(const hash_table_t *ht, const char *key)
1920
if (index >= ht->size)
2021
return (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
}

0x1A-hash_tables/e

16.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)