Download Tutorial C Files H Files

dg_get_entity

This function is used to get an entity from an array.

Usage

dg_entity_t *dg_get_entity(dg_array_t *entities, char *name);

Example

dg_entity_t *entity = dg_get_entity(entities, "mouse");

Source code

dg_entity_t *dg_get_entity(dg_array_t *entities, char *name)
{
    dg_entity_t *ent = 0;

    if (!entities || !name)
        return 0;
    while (entities && entities->data) {
        ent = ((dg_entity_t *)(entities->data));
        if (!dg_strcmp(ent->name, name))
            return ent;
        entities = entities->next;
    }
    return 0;
}