Skip to content

Commit

Permalink
Update dict.c
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanByte authored May 29, 2024
1 parent e5dad3f commit 9e688b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions data_structures/dictionary/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int add_item_label(Dictionary *dic, char label[], void *item)
unsigned int index = get_hash(label);

/* make sure index is fitting */
if (index < MAXELEMENTS)
if (index < MAXELEMENTS && dic->elements[index] == NULL)
{
dic->elements[index] = item;
return 0;
Expand Down Expand Up @@ -97,4 +97,4 @@ void *get_element_index(Dictionary *dict, int index)
return NULL;
}

void destroy(Dictionary *dict) { free(dict); }
void destroy(Dictionary *dict) { free(dict); }

0 comments on commit 9e688b8

Please sign in to comment.