diff options
author | Azat Khuzhin <azat@libevent.org> | 2019-02-10 16:23:11 +0300 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2019-02-10 16:23:58 +0300 |
commit | 9c75c24caa7689c010864579e27b159665c8dd63 (patch) | |
tree | f1927df666ed30684005191765cb07da857984b3 /sample/dns-example.c | |
parent | e7ff4ef2b4fc950a765008c18e74281cdb5e7668 (diff) | |
parent | 900f5c4503208c654c0e9ef64ac196c0deac5c18 (diff) | |
download | libevent-release-2.1.9-beta.tar.gz |
Merge branch 'release-2.1.9-beta-pull' into patches-2.1release-2.1.9-beta
* release-2.1.9-beta-pull:
Bump version to 2.1.9-beta everywhere
Bump ChangeLog
Bump AUTHORS section
...
Tested on (cmake/autotools):
- ubuntu
- freebsd
- osx
- windows
- netbsd
- solaris
- centos
Closes: #744
Diffstat (limited to 'sample/dns-example.c')
-rw-r--r-- | sample/dns-example.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sample/dns-example.c b/sample/dns-example.c index fb705664..21a75de8 100644 --- a/sample/dns-example.c +++ b/sample/dns-example.c @@ -78,6 +78,8 @@ gai_callback(int err, struct evutil_addrinfo *ai, void *arg) { const char *name = arg; int i; + struct evutil_addrinfo *first_ai = ai; + if (err) { printf("%s: %s\n", name, evutil_gai_strerror(err)); } @@ -99,6 +101,9 @@ gai_callback(int err, struct evutil_addrinfo *ai, void *arg) printf("[%d] %s: %s\n",i,name,buf); } } + + if (first_ai) + evutil_freeaddrinfo(first_ai); } static void @@ -154,19 +159,19 @@ main(int c, char **v) { const char *ns; }; struct options o; - char opt; + int opt; struct event_base *event_base = NULL; struct evdns_base *evdns_base = NULL; memset(&o, 0, sizeof(o)); - + if (c < 2) { fprintf(stderr, "syntax: %s [-x] [-v] [-c resolv.conf] [-s ns] hostname\n", v[0]); fprintf(stderr, "syntax: %s [-T]\n", v[0]); return 1; } - while ((opt = getopt(c, v, "xvc:Ts:")) != -1) { + while ((opt = getopt(c, v, "xvc:Ts:g")) != -1) { switch (opt) { case 'x': o.reverse = 1; break; case 'v': ++verbose; break; @@ -252,6 +257,8 @@ main(int c, char **v) { } fflush(stdout); event_base_dispatch(event_base); + evdns_base_free(evdns_base, 1); + event_base_free(event_base); return 0; } |