From e678f009a82b38745baac9874a3573136d0658b6 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Sun, 9 Sep 2007 01:46:35 +0000 Subject: [PATCH] fix a couple memory leaks; time buffer marshaling svn:r417 --- test/regress.c | 16 +++++++++++++--- test/regress_http.c | 2 ++ test/regress_rpc.c | 4 ++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/test/regress.c b/test/regress.c index 99ba2b41..b02cfced 100644 --- a/test/regress.c +++ b/test/regress.c @@ -602,6 +602,8 @@ test_evbuffer(void) { strcmp((char*)EVBUFFER_DATA(evb), "hello/1") == 0) test_ok = 1; + evbuffer_free(evb); + cleanup_test(); } @@ -970,6 +972,7 @@ rpc_test(void) struct kill *kill; struct run *run; struct evbuffer *tmp = evbuffer_new(); + struct timeval tv_start, tv_end; int i; fprintf(stdout, "Testing RPC: "); @@ -986,13 +989,14 @@ rpc_test(void) EVTAG_ASSIGN(kill, weapon, "feather"); EVTAG_ASSIGN(kill, action, "tickle"); - for (i = 0; i < 3; ++i) { + gettimeofday(&tv_start, NULL); + for (i = 0; i < 1000; ++i) { run = EVTAG_ADD(msg, run); if (run == NULL) { fprintf(stderr, "Failed to add run message.\n"); exit(1); } - EVTAG_ASSIGN(run, how, "very fast"); + EVTAG_ASSIGN(run, how, "very fast but with some data in it"); } if (msg_complete(msg) == -1) { @@ -1008,6 +1012,12 @@ rpc_test(void) exit(1); } + gettimeofday(&tv_end, NULL); + timersub(&tv_end, &tv_start, &tv_end); + fprintf(stderr, "(%.1f us/add) ", + (float)tv_end.tv_sec/(float)i * 1000000.0 + + tv_end.tv_usec / (float)i); + if (!EVTAG_HAS(msg2, from_name) || !EVTAG_HAS(msg2, to_name) || !EVTAG_HAS(msg2, kill)) { @@ -1015,7 +1025,7 @@ rpc_test(void) exit(1); } - if (EVTAG_LEN(msg2, run) != 3) { + if (EVTAG_LEN(msg2, run) != i) { fprintf(stderr, "Wrong number of run messages.\n"); exit(1); } diff --git a/test/regress_http.c b/test/regress_http.c index 2b99d0d1..4a59dff4 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -756,6 +756,8 @@ http_bad_header_test(void) if (evhttp_add_header(&headers, "One", "Two\n") != -1) goto fail; + evhttp_clear_headers(&headers); + fprintf(stdout, "OK\n"); return; fail: diff --git a/test/regress_rpc.c b/test/regress_rpc.c index 56462763..4e66ff53 100644 --- a/test/regress_rpc.c +++ b/test/regress_rpc.c @@ -199,6 +199,8 @@ rpc_basic_test(void) event_dispatch(); + evhttp_connection_free(evcon); + rpc_teardown(base); if (test_ok != 1) { @@ -286,6 +288,8 @@ rpc_basic_message(void) test_ok = 0; event_dispatch(); + + evhttp_connection_free(evcon); rpc_teardown(base);