5 #include <event2/event.h>
14 #include <boost/test/unit_test.hpp>
18 #ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
20 static std::map<void*, short> tags;
21 static std::map<void*, uint16_t> orders;
22 static uint16_t tagSequence = 0;
24 static void* tag_malloc(
size_t sz) {
25 void* mem = malloc(sz);
28 orders[mem] = tagSequence++;
32 static void tag_free(
void* mem) {
34 orders[mem] = tagSequence++;
40 event_set_mem_functions(tag_malloc, realloc, tag_free);
42 void* base_ptr =
nullptr;
45 base_ptr = (
void*)base.get();
50 void* event_ptr =
nullptr;
53 auto event =
obtain_event(base.get(), -1, 0,
nullptr,
nullptr);
55 base_ptr = (
void*)base.get();
56 event_ptr = (
void*)event.get();
64 event_set_mem_functions(malloc, realloc, free);
69 event_set_mem_functions(tag_malloc, realloc, tag_free);
71 void* base_ptr =
nullptr;
72 void* event_ptr =
nullptr;
75 auto event =
obtain_event(base.get(), -1, 0,
nullptr,
nullptr);
77 base_ptr = (
void*)base.get();
78 event_ptr = (
void*)event.get();
86 event_set_mem_functions(malloc, realloc, free);
94 BOOST_TEST_MESSAGE(
"Skipping raii_event_tess: libevent doesn't support event_set_mem_functions");
BOOST_AUTO_TEST_SUITE_END()
raii_event obtain_event(struct event_base *base, evutil_socket_t s, short events, event_callback_fn cb, void *arg)
raii_event_base obtain_event_base()
#define BOOST_CHECK(expr)
BOOST_AUTO_TEST_CASE(raii_event_tests_SKIPPED)