mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Update sample/signal-test.c to use newer APIs and not leak.
This commit is contained in:
parent
ea6b1df288
commit
f6430ac1e3
@ -49,6 +49,7 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct event signal_int;
|
||||
struct event_base* base;
|
||||
#ifdef WIN32
|
||||
WORD wVersionRequested;
|
||||
WSADATA wsaData;
|
||||
@ -60,15 +61,16 @@ main (int argc, char **argv)
|
||||
#endif
|
||||
|
||||
/* Initalize the event library */
|
||||
event_init();
|
||||
base = event_base_new();
|
||||
|
||||
/* Initalize one event */
|
||||
event_set(&signal_int, SIGINT, EV_SIGNAL|EV_PERSIST, signal_cb,
|
||||
event_assign(&signal_int, base, SIGINT, EV_SIGNAL|EV_PERSIST, signal_cb,
|
||||
&signal_int);
|
||||
|
||||
event_add(&signal_int, NULL);
|
||||
|
||||
event_dispatch();
|
||||
event_base_dispatch(base);
|
||||
event_base_free(base);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user