Depth-Studios
Welcome guest (Login / Register)
destroy vector all

Definition


void destroy_vector_all(vector_t *vector, free_vector_value_t free_func);


Description


Frees memory from the structure. This function does free the single elements.


Parameters


vector
Vector to free
free_func
Function that can free an element. When this is NULL, the normal libc_free() is used.


Return Value


void.


Example


#include <stdio.h>
#include <libc/string.h>
 
void custom_free(void *ptr)
{
	free(ptr);
}
 
int main(int argc, char *argv[])
{
	vector_t *vector = create_vector();
	void *ptr = malloc(1000);
 
	push_vector(vector, ptr);
 
	destroy_vector_all(vector, custom_free);
 
	return 0;
}