mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Merge pull request #207 from azat/avoid-leaking-of-event_debug_map_HT_GROW
Avoid leaking of event_debug_map_HT_GROW
This commit is contained in:
commit
51821e20b2
9
event.c
9
event.c
@ -526,22 +526,24 @@ event_enable_debug_mode(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
event_disable_debug_mode(void)
|
||||
{
|
||||
#ifndef EVENT__DISABLE_DEBUG_MODE
|
||||
struct event_debug_entry **ent, *victim;
|
||||
|
||||
EVLOCK_LOCK(event_debug_map_lock_, 0);
|
||||
for (ent = HT_START(event_debug_map, &global_debug_map); ent; ) {
|
||||
victim = *ent;
|
||||
ent = HT_NEXT_RMV(event_debug_map,&global_debug_map, ent);
|
||||
ent = HT_NEXT_RMV(event_debug_map, &global_debug_map, ent);
|
||||
mm_free(victim);
|
||||
}
|
||||
HT_CLEAR(event_debug_map, &global_debug_map);
|
||||
EVLOCK_UNLOCK(event_debug_map_lock_ , 0);
|
||||
}
|
||||
|
||||
event_debug_mode_on_ = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct event_base *
|
||||
event_base_new_with_config(const struct event_config *cfg)
|
||||
@ -3798,6 +3800,7 @@ event_free_globals(void)
|
||||
void
|
||||
libevent_global_shutdown(void)
|
||||
{
|
||||
event_disable_debug_mode();
|
||||
event_free_globals();
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,6 @@ ht_string_hash_(const char *s)
|
||||
{ \
|
||||
if (head->hth_table) \
|
||||
freefn(head->hth_table); \
|
||||
head->hth_table_length = 0; \
|
||||
name##_HT_INIT(head); \
|
||||
} \
|
||||
/* Debugging helper: return false iff the representation of 'head' is \
|
||||
|
@ -1804,9 +1804,15 @@ testleak_setup(const struct testcase_t *testcase)
|
||||
struct testleak_env_t *env;
|
||||
|
||||
allocated_chunks = 0;
|
||||
|
||||
/* Reset allocation counter, to start allocations from the very beginning.
|
||||
* (this will avoid false-positive negative numbers for allocated_chunks)
|
||||
*/
|
||||
libevent_global_shutdown();
|
||||
|
||||
event_set_mem_functions(cnt_malloc, cnt_realloc, cnt_free);
|
||||
if (!libevent_tests_running_in_debug_mode)
|
||||
event_enable_debug_mode();
|
||||
|
||||
event_enable_debug_mode();
|
||||
|
||||
/* not mm_calloc: we don't want to mess with the count. */
|
||||
env = calloc(1, sizeof(struct testleak_env_t));
|
||||
@ -1827,8 +1833,8 @@ testleak_cleanup(const struct testcase_t *testcase, void *env_)
|
||||
#ifdef EVENT__DISABLE_DEBUG_MODE
|
||||
tt_int_op(allocated_chunks, ==, 0);
|
||||
#else
|
||||
/* FIXME: that's `1' because of event_debug_map_HT_GROW */
|
||||
tt_int_op(allocated_chunks, ==, 1);
|
||||
libevent_global_shutdown();
|
||||
tt_int_op(allocated_chunks, ==, 0);
|
||||
#endif
|
||||
ok = 1;
|
||||
end:
|
||||
|
Loading…
x
Reference in New Issue
Block a user