5 #include <event2/event.h>
7 #ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
17 #include <boost/test/unit_test.hpp>
19 static std::map<void*, short> tags;
20 static std::map<void*, uint16_t> orders;
21 static uint16_t tagSequence = 0;
23 static void* tag_malloc(
size_t sz) {
24 void* mem = malloc(sz);
27 orders[mem] = tagSequence++;
31 static void tag_free(
void* mem) {
33 orders[mem] = tagSequence++;
41 event_set_mem_functions(tag_malloc, realloc, tag_free);
43 void* base_ptr =
nullptr;
46 base_ptr = (
void*)base.get();
51 void* event_ptr =
nullptr;
54 auto event =
obtain_event(base.get(), -1, 0,
nullptr,
nullptr);
56 base_ptr = (
void*)base.get();
57 event_ptr = (
void*)event.get();
65 event_set_mem_functions(malloc, realloc, free);
70 event_set_mem_functions(tag_malloc, realloc, tag_free);
72 void* base_ptr =
nullptr;
73 void* event_ptr =
nullptr;
76 auto event =
obtain_event(base.get(), -1, 0,
nullptr,
nullptr);
78 base_ptr = (
void*)base.get();
79 event_ptr = (
void*)event.get();
87 event_set_mem_functions(malloc, realloc, free);
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_FIXTURE_TEST_SUITE(a, b)
#define BOOST_AUTO_TEST_CASE(funcName)
#define BOOST_CHECK(expr)