mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 21:10:06 -04: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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
void
|
void
|
||||||
event_disable_debug_mode(void)
|
event_disable_debug_mode(void)
|
||||||
{
|
{
|
||||||
|
#ifndef EVENT__DISABLE_DEBUG_MODE
|
||||||
struct event_debug_entry **ent, *victim;
|
struct event_debug_entry **ent, *victim;
|
||||||
|
|
||||||
EVLOCK_LOCK(event_debug_map_lock_, 0);
|
EVLOCK_LOCK(event_debug_map_lock_, 0);
|
||||||
for (ent = HT_START(event_debug_map, &global_debug_map); ent; ) {
|
for (ent = HT_START(event_debug_map, &global_debug_map); ent; ) {
|
||||||
victim = *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);
|
mm_free(victim);
|
||||||
}
|
}
|
||||||
HT_CLEAR(event_debug_map, &global_debug_map);
|
HT_CLEAR(event_debug_map, &global_debug_map);
|
||||||
EVLOCK_UNLOCK(event_debug_map_lock_ , 0);
|
EVLOCK_UNLOCK(event_debug_map_lock_ , 0);
|
||||||
}
|
|
||||||
|
event_debug_mode_on_ = 0;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
struct event_base *
|
struct event_base *
|
||||||
event_base_new_with_config(const struct event_config *cfg)
|
event_base_new_with_config(const struct event_config *cfg)
|
||||||
@ -3798,6 +3800,7 @@ event_free_globals(void)
|
|||||||
void
|
void
|
||||||
libevent_global_shutdown(void)
|
libevent_global_shutdown(void)
|
||||||
{
|
{
|
||||||
|
event_disable_debug_mode();
|
||||||
event_free_globals();
|
event_free_globals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +380,6 @@ ht_string_hash_(const char *s)
|
|||||||
{ \
|
{ \
|
||||||
if (head->hth_table) \
|
if (head->hth_table) \
|
||||||
freefn(head->hth_table); \
|
freefn(head->hth_table); \
|
||||||
head->hth_table_length = 0; \
|
|
||||||
name##_HT_INIT(head); \
|
name##_HT_INIT(head); \
|
||||||
} \
|
} \
|
||||||
/* Debugging helper: return false iff the representation of 'head' is \
|
/* 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;
|
struct testleak_env_t *env;
|
||||||
|
|
||||||
allocated_chunks = 0;
|
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);
|
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. */
|
/* not mm_calloc: we don't want to mess with the count. */
|
||||||
env = calloc(1, sizeof(struct testleak_env_t));
|
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
|
#ifdef EVENT__DISABLE_DEBUG_MODE
|
||||||
tt_int_op(allocated_chunks, ==, 0);
|
tt_int_op(allocated_chunks, ==, 0);
|
||||||
#else
|
#else
|
||||||
/* FIXME: that's `1' because of event_debug_map_HT_GROW */
|
libevent_global_shutdown();
|
||||||
tt_int_op(allocated_chunks, ==, 1);
|
tt_int_op(allocated_chunks, ==, 0);
|
||||||
#endif
|
#endif
|
||||||
ok = 1;
|
ok = 1;
|
||||||
end:
|
end:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user