Skip to content
Snippets Groups Projects
Commit d620a77f authored by abivarma.kandiah's avatar abivarma.kandiah
Browse files

Add Vector Free

parent 99e13923
No related branches found
No related tags found
No related merge requests found
...@@ -28,5 +28,6 @@ type vector_get(vector vec, int index); ...@@ -28,5 +28,6 @@ type vector_get(vector vec, int index);
type vector_remove(vector vec, int index); type vector_remove(vector vec, int index);
void vector_insert(vector vec, type element, int index); void vector_insert(vector vec, type element, int index);
void vector_empty(vector vec); void vector_empty(vector vec);
void vector_free(vector vec);
#endif #endif
\ No newline at end of file
...@@ -49,6 +49,10 @@ int main() ...@@ -49,6 +49,10 @@ int main()
vector_empty(test); vector_empty(test);
printf("Empty Vector lenght : %d \n", vector_length(test)); printf("Empty Vector lenght : %d \n", vector_length(test));
//Test Vector Free
vector_free(test);
return 0; return 0;
} }
\ No newline at end of file
...@@ -122,3 +122,9 @@ void vector_empty(vector vec) ...@@ -122,3 +122,9 @@ void vector_empty(vector vec)
vec->content = realloc(vec->content, sizeof(type) * vec->capacity); vec->content = realloc(vec->content, sizeof(type) * vec->capacity);
assert(vec->content != NULL); assert(vec->content != NULL);
} }
void vector_free(vector vec)
{
free(vec->content);
free(vec);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment