ellzey/libevhtp — pull request #38 by jbro (2012-03-28 14:26:10+00:00)
Title: Added function evhtp_unbind_socket

evhtp_unbind_socket stops listen socket, and deallocs all memomry
allocated by evhtp_new.

Valgrind with code:
int
main(int argc, char ** argv) {
evbase_t * evbase = event_base_new();
evhtp_t * htp = evhtp_new(evbase, NULL);
evhtp_callback_t * cb;

cb = evhtp_set_cb(htp, "/test", testcb, NULL);
evhtp_callback_free(cb);
evhtp_bind_socket(htp, "0.0.0.0", 8080, 1024);

return 0;
}

==11359== Memcheck, a memory error detector
==11359== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==11359== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==11359== Command: ./test_basic
==11359==
==11359==
==11359== HEAP SUMMARY:
==11359== in use at exit: 12,136 bytes in 57 blocks
==11359== total heap usage: 60 allocs, 3 frees, 12,230 bytes allocated
==11359==
==11359== LEAK SUMMARY:
==11359== definitely lost: 632 bytes in 1 blocks
==11359== indirectly lost: 9,248 bytes in 9 blocks
==11359== possibly lost: 0 bytes in 0 blocks
==11359== still reachable: 2,256 bytes in 47 blocks
==11359== suppressed: 0 bytes in 0 blocks
==11359== Rerun with --leak-check=full to see details of leaked memory
==11359==
==11359== For counts of detected and suppressed errors, rerun with: -v
==11359== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)

Valgrind with code:
int
main(int argc, char ** argv) {
evbase_t * evbase = event_base_new();
evhtp_t * htp = evhtp_new(evbase, NULL);
evhtp_callback_t * cb;

cb = evhtp_set_cb(htp, "/test", testcb, NULL);
evhtp_callback_free(cb);
evhtp_bind_socket(htp, "0.0.0.0", 8080, 1024);

evhtp_unbind_socket(htp, 1);
free(htp);
event_base_free(evbase);
return 0;
}

==11264== Memcheck, a memory error detector
==11264== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==11264== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==11264== Command: ./test_basic
==11264==
==11264==
==11264== HEAP SUMMARY:
==11264== in use at exit: 8,216 bytes in 2 blocks
==11264== total heap usage: 60 allocs, 58 frees, 12,230 bytes allocated
==11264==
==11264== LEAK SUMMARY:
==11264== definitely lost: 24 bytes in 1 blocks
==11264== indirectly lost: 8,192 bytes in 1 blocks
==11264== possibly lost: 0 bytes in 0 blocks
==11264== still reachable: 0 bytes in 0 blocks
==11264== suppressed: 0 bytes in 0 blocks
==11264== Rerun with --leak-check=full to see details of leaked memory
==11264==
==11264== For counts of detected and suppressed errors, rerun with: -v
==11264== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)