ext/iodine/fio.c
/** Adds a callback to the list of callbacks to be called for the event. */
Adds a callback to the list of callbacks to be called for the event.
Adds a callback to the list of callbacks to be called for the event .
void fio_state_callback_add(callback_type_e c_type, void (*func)(void *),
                            void *arg) {
  if (c_type == FIO_CALL_ON_INITIALIZE && fio_data) {
    func(arg);
    return;
  }
  if (!func || (int)c_type < 0 || c_type > FIO_CALL_NEVER)
    return;
  fio_lock(&callback_collection[c_type].lock);
  fio_state_callback_ensure(&callback_collection[c_type]);
  callback_data_s *tmp = malloc(sizeof(*tmp));
  FIO_ASSERT_ALLOC(tmp);
  *tmp = (callback_data_s){.func = func, .arg = arg};
  fio_ls_embd_push(&callback_collection[c_type].callbacks, &tmp->node);
  fio_unlock(&callback_collection[c_type].lock);
}
void fio_state_callback_add ( callback_type_e c_type , void ( * func ) ( void * ) , void * arg ) { if ( c_type == FIO_CALL_ON_INITIALIZE && fio_data ) { func ( arg ) ; return ; } if ( ! func || ( int ) c_type < 0 || c_type > FIO_CALL_NEVER ) return ; fio_lock ( & callback_collection [ c_type ] . lock ) ; fio_state_callback_ensure ( & callback_collection [ c_type ] ) ; callback_data_s * tmp = malloc ( sizeof ( * tmp ) ) ; FIO_ASSERT_ALLOC ( tmp ) ; * tmp = ( callback_data_s ) { . func = func , . arg = arg } ; fio_ls_embd_push ( & callback_collection [ c_type ] . callbacks , & tmp -> node ) ; fio_unlock ( & callback_collection [ c_type ] . lock ) ; }
Adds a callback to the list of callbacks to be called for the event.
Adds a callback to the list of callbacks to be called for the event .