void inline_size select_destroy (EV_P) { ev_free (vec_ri); ev_free (vec_ro); ev_free (vec_wi); ev_free (vec_wo); }
inline_size void select_destroy (EV_P) { ev_free (vec_ri); ev_free (vec_ro); ev_free (vec_wi); ev_free (vec_wo); #ifdef _WIN32 ev_free (vec_eo); #endif }
void ev_vbuff_destroy(ev_vbuff* v) { if( v ) { dispose(v); ev_free(v); } }
void ev_texture_destroy(ev_texture *t) { if( t ) { if( t->id ) { glDeleteTextures(1, &t->id); t->id = 0; } ev_free(t); } }
static void dispose(ev_vbuff *v) { assert( v != NULL ); if( v->id ) { glDeleteBuffers(1, &v->id); v->id = 0; } if( v->buff ) { ev_free(v->buff); v->buff = NULL; } v->size = 0; }
int main(int ac, char **av) { int ret; struct ospfd *ospfd; int ev_flags = 0; ospfd = alloc_ospfd(); ret = parse_cli_options(ospfd, ac, av); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Can't parse command line"); msg(ospfd, GENTLE, PROGRAMNAME " - " VERSIONSTRING); /* seed pseudo number randon generator */ init_pnrg(ospfd); /* initialize event subsystem. In this case this belongs * to open a epoll filedescriptor */ ospfd->ev = ev_new(); if (!ospfd->ev) err_msg_die(EXIT_FAILURE, "Can't initialize event subsystem"); ret = parse_rc_file(ospfd); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Can't parse configuration file"); ret = init_network(ospfd); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Can't initialize network subsystem"); /* and branch into the main loop * This loop will never return (with the exception of SIGINT or failure * condition) */ ret = ev_loop(ospfd->ev, ev_flags); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Main loop returned unexpected - exiting now"); fini_network(ospfd); free_options(ospfd); ev_free(ospfd->ev); free_ospfd(ospfd); return EXIT_SUCCESS; }
ev_err_t ev_arraylist_reserve(ev_arraylist *al, size_t s) { void **p = ev_malloc(s * sizeof(void*)); if( !p ) { return EV_NOMEM; } memcpy(p, al->buff, (al->top-1) * sizeof(void*)); ev_free(al->buff); al->buff = p; al->len = s; return EV_OK; }
static void port_poll (EV_P_ ev_tstamp timeout) { int res, i; struct timespec ts; uint_t nget = 1; EV_RELEASE_CB; ts.tv_sec = (time_t)timeout; ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9; res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts); EV_ACQUIRE_CB; if (res == -1) { if (errno != EINTR && errno != ETIME) ev_syserr ("(libev) port_getn"); return; } for (i = 0; i < nget; ++i) { if (port_events [i].portev_source == PORT_SOURCE_FD) { int fd = port_events [i].portev_object; fd_event ( EV_A_ fd, (port_events [i].portev_events & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) | (port_events [i].portev_events & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) ); port_associate_and_check (EV_A_ fd, anfds [fd].events); } } if (expect_false (nget == port_eventmax)) { ev_free (port_events); port_eventmax = array_nextsize (sizeof (port_event_t), port_eventmax, port_eventmax + 1); port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); } }
static ev_err_t grow_list(ev_arraylist *al) { void *b; size_t new_size = (al->len * 3) / 2; b = ev_malloc(new_size * sizeof(void*)); if( !b ) return EV_NOMEM; memcpy(b, al->buff, al->top * sizeof(void*)); ev_free(al->buff); al->buff = b; al->len = new_size; return EV_OK; }
void worker_cleanup(worker_t* self) { int n, i, s; // FIXPAUL; this wont clean connections that are currently in the WAIT state... for (n = 0; n <= self->loop.max_fd; n++) { if (self->loop.events[n].userdata) { s = 1; for (i = 0; i < num_workers; i++) { if (workers[i] == self->loop.events[n].userdata) s = 0; } if (s == 1) conn_close((conn_t *) self->loop.events[n].userdata); } } ev_free(&self->loop); }
void inline_size poll_destroy (EV_P) { ev_free (pollidxs); ev_free (polls); }
static void kqueue_poll (EV_P_ ev_tstamp timeout) { int res, i; struct timespec ts; /* need to resize so there is enough space for errors */ if (kqueue_changecnt > kqueue_eventmax) { ev_free (kqueue_events); kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt); kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); } EV_RELEASE_CB; EV_TS_SET (ts, timeout); res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts); EV_ACQUIRE_CB; kqueue_changecnt = 0; if (expect_false (res < 0)) { if (errno != EINTR) ev_syserr ("(libev) kevent"); return; } for (i = 0; i < res; ++i) { int fd = kqueue_events [i].ident; if (expect_false (kqueue_events [i].flags & EV_ERROR)) { int err = kqueue_events [i].data; /* we are only interested in errors for fds that we are interested in :) */ if (anfds [fd].events) { if (err == ENOENT) /* resubmit changes on ENOENT */ kqueue_modify (EV_A_ fd, 0, anfds [fd].events); else if (err == EBADF) /* on EBADF, we re-check the fd */ { if (fd_valid (fd)) kqueue_modify (EV_A_ fd, 0, anfds [fd].events); else fd_kill (EV_A_ fd); } else /* on all other errors, we error out on the fd */ fd_kill (EV_A_ fd); } } else fd_event ( EV_A_ fd, kqueue_events [i].filter == EVFILT_READ ? EV_READ : kqueue_events [i].filter == EVFILT_WRITE ? EV_WRITE : 0 ); } if (expect_false (res == kqueue_eventmax)) { ev_free (kqueue_events); kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_eventmax + 1); kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax); } }
void inline_size kqueue_destroy (EV_P) { ev_free (kqueue_events); ev_free (kqueue_changes); }
void inline_size port_destroy (EV_P) { ev_free (port_events); }