This function is used to destroy a component.
void dg_component_destroy(dg_component_t *component);
dg_component_destroy(component);
void dg_component_destroy(dg_component_t *component)
{
if (!component)
return;
component->on_destroy(component->data);
free(component);
}