src/libmetha/events.c
M_CODE
lmetha_attach_observer(struct metha *m, int type,
                       M_CODE (*callback)(void *, void *), void *private)
{
    if (type >= LM_EV_COUNT)
        return M_FAILED;

    struct observer_pool *pool = &m->observer_pool[type];

    if (!(pool->o = realloc(pool->o, (pool->count+1)*sizeof(struct observer))))
        return M_OUT_OF_MEM;

    pool->o[pool->count].arg2     = private;
    pool->o[pool->count].callback = callback;
    pool->count ++;

    return M_OK;
}
/** 
 * Attach an observer callback to the given event. 'private' will
 * be sent as the second argument to the callback when it is invoked,
 * 'm' will always be sent as the first argument to the callback.
 **/
Attach an observer callback to the given event. 'private' will
be sent as the second argument to the callback when it is invoked,
'm' will always be sent as the first argument to the callback.
Attach an observer callback to the given event . ' private ' will be sent as the second argument to the callback when it is invoked ' m ' will always be sent as the first argument to the callback .
M_CODE
lmetha_attach_observer(struct metha *m, int type,
                       M_CODE (*callback)(void *, void *), void *private)
{
    if (type >= LM_EV_COUNT)
        return M_FAILED;
    struct observer_pool *pool = &m->observer_pool[type];
    if (!(pool->o = realloc(pool->o, (pool->count+1)*sizeof(struct observer))))
        return M_OUT_OF_MEM;
    pool->o[pool->count].arg2     = private;
    pool->o[pool->count].callback = callback;
    pool->count ++;
    return M_OK;
}
M_CODE lmetha_attach_observer ( struct metha * m , int type , M_CODE ( * callback ) ( void * , void * ) , void * private ) { if ( type >= LM_EV_COUNT ) return M_FAILED ; struct observer_pool * pool = & m -> observer_pool [ type ] ; if ( ! ( pool -> o = realloc ( pool -> o , ( pool -> count + 1 ) * sizeof ( struct observer ) ) ) ) return M_OUT_OF_MEM ; pool -> o [ pool -> count ] . arg2 = private ; pool -> o [ pool -> count ] . callback = callback ; pool -> count ++ ; return M_OK ; }
Attach an observer callback to the given event.
Attach an observer callback to the given event .