struct ast_timer *ast_timer_open(void) { int fd = -1; struct timing_holder *h; struct ast_timer *t = NULL; ast_heap_rdlock(timing_interfaces); if ((h = ast_heap_peek(timing_interfaces, 1))) { fd = h->iface->timer_open(); ast_module_ref(h->mod); } if (fd != -1) { if (!(t = ast_calloc(1, sizeof(*t)))) { h->iface->timer_close(fd); } else { t->fd = fd; t->holder = h; } } ast_heap_unlock(timing_interfaces); return t; }
struct ast_timer *ast_timer_open(void) { void *data = NULL; struct timing_holder *h; struct ast_timer *t = NULL; ast_heap_rdlock(timing_interfaces); if ((h = ast_heap_peek(timing_interfaces, 1))) { data = h->iface->timer_open(); ast_module_ref(h->mod); } if (data) { if (!(t = ast_calloc(1, sizeof(*t)))) { h->iface->timer_close(data); } else { t->data = data; t->holder = h; } } ast_heap_unlock(timing_interfaces); return t; }