Skip to content

Commit

Permalink
set size to 0 when vector get cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbui904 committed Feb 3, 2022
1 parent 2b83581 commit 74c01ac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Binary file modified assignment9-starter/tester
Binary file not shown.
3 changes: 2 additions & 1 deletion assignment9-starter/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ param: VECTOR *vector
void cleanup(Vector *vector)
{
free(vector->array);
vector->size = 0;
}

/* Deletes value at location inside the Vector. Return 1 for success, otherwise
Expand All @@ -141,7 +142,7 @@ int delete (Vector *vector, int location)
for (int i = location; i < vector->size; i++)
{
//store the next value and swap with the previous one
vector->array[i] = vector->array[i+1];
vector->array[i] = vector->array[i + 1];
}
}
vector->size = vector->size - 1;
Expand Down

0 comments on commit 74c01ac

Please sign in to comment.