tg/event-old.h

25 lines
678 B
C
Raw Normal View History

2014-09-07 15:12:39 -04:00
#ifndef __EVENT_OLD_H__
#define __EVENT_OLD_H__
2014-09-07 17:50:19 -04:00
typedef int evutil_socket_t;
2014-09-07 15:12:39 -04:00
static inline struct event *event_new (struct event_base *base, int fd, int what, void(*callback)(int, short, void *), void *arg) {
2014-09-08 08:40:35 -04:00
struct event *ev = malloc (sizeof (*ev));
event_set (ev, fd, what, callback, arg);
event_base_set (base, ev);
return ev;
2014-09-07 15:12:39 -04:00
}
static inline struct event *evtimer_new (struct event_base *base, void(*callback)(int, short, void *), void *arg) {
2014-09-08 08:40:35 -04:00
struct event *ev = malloc (sizeof (*ev));
event_set (ev, -1, 0, callback, arg);
event_base_set (base, ev);
return ev;
2014-09-07 15:12:39 -04:00
}
static void event_free (struct event *ev) {
event_del (ev);
free (ev);
}
#endif