Download Tutorial C Files H Files

dg_component_create

This function is used to create a component.

Usage

dg_component_t *dg_component_create(char *name, void *data, dg_cpt_destroy_t cff);

Example

dg_component_t *component = dg_component_create("score", score,
    &component_destroy);

Source code

dg_component_t *dg_component_create(char *name, void *data,
    dg_cpt_destroy_t cff)
{
    dg_component_t *component = malloc(sizeof(dg_component_t));

    if (!component)
        return 0;
    component->name = name;
    component->data = data;
    component->on_destroy = cff;
    return component;
}