Move wmem to wsutil
This allows wmem to be used from other libraries, namely wsutil. It is often the case that a funtion exists in wsutil and cannot be used with a wmem scope, requiring some code duplication or extra memory allocations, or vice-versa, code in epan cannot be moved to wsutil because it has a wmem dependency. To this end wmem is moved to wsutil. Scope management remains part of epan because those scope semantics are specific to dissection.
This commit is contained in:
parent
8310665ae7
commit
7f9c1f5f92
|
@ -1913,7 +1913,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
uat_update_record@Base 1.99.3
|
||||
udp_dissect_pdus@Base 1.99.3
|
||||
udp_port_to_display@Base 1.99.2
|
||||
uint64_compare@Base 3.5.0
|
||||
uint_to_str_back@Base 2.1.0
|
||||
union_of_tap_listener_flags@Base 1.9.1
|
||||
unit_name_string_get_value@Base 2.3.0
|
||||
|
@ -2002,108 +2001,11 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
value_is_in_range@Base 1.9.1
|
||||
value_string_ext_free@Base 1.12.0~rc1
|
||||
value_string_ext_new@Base 1.9.1
|
||||
wmem_alloc0@Base 1.9.1
|
||||
wmem_alloc@Base 1.9.1
|
||||
wmem_allocator_new@Base 1.9.1
|
||||
wmem_array_append@Base 1.12.0~rc1
|
||||
wmem_array_bzero@Base 2.1.0
|
||||
wmem_array_get_count@Base 1.12.0~rc1
|
||||
wmem_array_get_raw@Base 1.12.0~rc1
|
||||
wmem_array_grow@Base 3.3.0
|
||||
wmem_array_index@Base 1.12.0~rc1
|
||||
wmem_array_new@Base 1.12.0~rc1
|
||||
wmem_array_set_null_terminator@Base 2.1.0
|
||||
wmem_array_sized_new@Base 1.12.0~rc1
|
||||
wmem_array_sort@Base 1.12.0~rc1
|
||||
wmem_array_try_index@Base 3.1.0
|
||||
wmem_ascii_strdown@Base 1.12.0~rc1
|
||||
wmem_cleanup@Base 1.12.0~rc1
|
||||
wmem_destroy_allocator@Base 1.9.1
|
||||
wmem_destroy_array@Base 3.3.0
|
||||
wmem_destroy_list@Base 1.12.0~rc1
|
||||
wmem_double_hash@Base 1.12.0~rc1
|
||||
wmem_epan_scope@Base 1.9.1
|
||||
wmem_file_scope@Base 1.9.1
|
||||
wmem_free@Base 1.9.1
|
||||
wmem_free_all@Base 1.9.1
|
||||
wmem_gc@Base 1.9.1
|
||||
wmem_init@Base 1.12.0~rc1
|
||||
wmem_int64_hash@Base 1.12.0~rc1
|
||||
wmem_itree_find_intervals@Base 2.1.0
|
||||
wmem_itree_insert@Base 2.1.0
|
||||
wmem_itree_is_empty@Base 2.1.0
|
||||
wmem_itree_new@Base 2.1.0
|
||||
wmem_list_append@Base 1.12.0~rc1
|
||||
wmem_list_count@Base 1.12.0~rc1
|
||||
wmem_list_find@Base 2.1.0
|
||||
wmem_list_find_custom@Base 2.3.0
|
||||
wmem_list_foreach@Base 2.1.0
|
||||
wmem_list_frame_data@Base 1.12.0~rc1
|
||||
wmem_list_frame_next@Base 1.12.0~rc1
|
||||
wmem_list_frame_prev@Base 1.12.0~rc1
|
||||
wmem_list_head@Base 1.12.0~rc1
|
||||
wmem_list_insert_sorted@Base 2.3.0
|
||||
wmem_list_new@Base 1.12.0~rc1
|
||||
wmem_list_prepend@Base 1.12.0~rc1
|
||||
wmem_list_remove@Base 1.12.0~rc1
|
||||
wmem_list_remove_frame@Base 1.12.0~rc1
|
||||
wmem_list_tail@Base 1.12.0~rc1
|
||||
wmem_map_contains@Base 2.5.1
|
||||
wmem_map_foreach@Base 2.1.0
|
||||
wmem_map_get_keys@Base 2.3.0
|
||||
wmem_map_insert@Base 1.12.0~rc1
|
||||
wmem_map_lookup@Base 1.12.0~rc1
|
||||
wmem_map_lookup_extended@Base 2.5.1
|
||||
wmem_map_new@Base 1.12.0~rc1
|
||||
wmem_map_new_autoreset@Base 2.3.0
|
||||
wmem_map_remove@Base 1.12.0~rc1
|
||||
wmem_map_size@Base 2.1.0
|
||||
wmem_map_steal@Base 2.3.0
|
||||
wmem_memdup@Base 1.12.0~rc1
|
||||
wmem_packet_scope@Base 1.9.1
|
||||
wmem_realloc@Base 1.9.1
|
||||
wmem_register_callback@Base 1.12.0~rc1
|
||||
wmem_stack_peek@Base 1.9.1
|
||||
wmem_stack_pop@Base 1.9.1
|
||||
wmem_str_hash@Base 1.12.0~rc1
|
||||
wmem_strbuf_append@Base 1.9.1
|
||||
wmem_strbuf_append_c@Base 1.12.0~rc1
|
||||
wmem_strbuf_append_len@Base 3.3.1
|
||||
wmem_strbuf_append_printf@Base 1.9.1
|
||||
wmem_strbuf_append_unichar@Base 1.12.0~rc1
|
||||
wmem_strbuf_append_vprintf@Base 3.1.1
|
||||
wmem_strbuf_finalize@Base 1.12.0~rc1
|
||||
wmem_strbuf_get_len@Base 1.9.1
|
||||
wmem_strbuf_get_str@Base 1.9.1
|
||||
wmem_strbuf_new@Base 1.9.1
|
||||
wmem_strbuf_sized_new@Base 1.9.1
|
||||
wmem_strbuf_truncate@Base 1.12.0~rc1
|
||||
wmem_strconcat@Base 1.12.0~rc1
|
||||
wmem_strdup@Base 1.9.1
|
||||
wmem_strdup_printf@Base 1.9.1
|
||||
wmem_strdup_vprintf@Base 1.9.1
|
||||
wmem_strjoin@Base 2.5.1
|
||||
wmem_strjoinv@Base 2.5.1
|
||||
wmem_strndup@Base 1.9.1
|
||||
wmem_strong_hash@Base 1.12.0~rc1
|
||||
wmem_strsplit@Base 1.12.0~rc1
|
||||
wmem_tree_count@Base 2.3.0
|
||||
wmem_tree_destroy@Base 2.3.0
|
||||
wmem_tree_foreach@Base 1.12.0~rc1
|
||||
wmem_tree_insert32@Base 1.12.0~rc1
|
||||
wmem_tree_insert32_array@Base 1.12.0~rc1
|
||||
wmem_tree_insert_string@Base 1.12.0~rc1
|
||||
wmem_tree_is_empty@Base 1.12.0~rc1
|
||||
wmem_tree_lookup32@Base 1.12.0~rc1
|
||||
wmem_tree_lookup32_array@Base 1.12.0~rc1
|
||||
wmem_tree_lookup32_array_le@Base 1.12.0~rc1
|
||||
wmem_tree_lookup32_le@Base 1.12.0~rc1
|
||||
wmem_tree_lookup_string@Base 1.12.0~rc1
|
||||
wmem_tree_new@Base 1.12.0~rc1
|
||||
wmem_tree_new_autoreset@Base 1.12.0~rc1
|
||||
wmem_tree_remove_string@Base 1.99.9
|
||||
wmem_tree_remove32@Base 2.3.0
|
||||
wmem_unregister_callback@Base 1.12.0~rc1
|
||||
wmem_cleanup_scopes@Base 3.5.0
|
||||
wmem_epan_scope@Base 3.5.0
|
||||
wmem_init_scopes@Base 3.5.0
|
||||
wmem_packet_scope@Base 3.5.0
|
||||
wmem_file_scope@Base 3.5.0
|
||||
word_to_hex@Base 2.1.0
|
||||
write_carrays_hex_data@Base 1.99.1
|
||||
write_csv_column_titles@Base 1.99.1
|
||||
|
|
|
@ -4,3 +4,4 @@ ws_compiler_tests.h usr/include/wireshark
|
|||
ws_diag_control.h usr/include/wireshark
|
||||
ws_symbol_export.h usr/include/wireshark
|
||||
wsutil/*.h usr/include/wireshark/wsutil
|
||||
wsutil/wmem/*.h usr/include/wireshark/wsutil/wmem
|
||||
|
|
|
@ -195,10 +195,116 @@ libwsutil.so.0 libwsutil0 #MINVER#
|
|||
tm_is_valid@Base 3.5.0
|
||||
type_util_gdouble_to_guint64@Base 1.10.0
|
||||
type_util_guint64_to_gdouble@Base 1.10.0
|
||||
uint64_compare@Base 3.5.0
|
||||
ulaw2linear@Base 1.12.0~rc1
|
||||
unix_epoch_to_nstime@Base 3.5.0
|
||||
update_adler32@Base 1.12.0~rc1
|
||||
update_crc10_by_bytes@Base 1.10.0
|
||||
wmem_alloc0@Base 3.5.0
|
||||
wmem_alloc@Base 3.5.0
|
||||
wmem_allocator_new@Base 3.5.0
|
||||
wmem_array_append@Base 3.5.0
|
||||
wmem_array_bzero@Base 3.5.0
|
||||
wmem_array_get_count@Base 3.5.0
|
||||
wmem_array_get_raw@Base 3.5.0
|
||||
wmem_array_grow@Base 3.5.0
|
||||
wmem_array_index@Base 3.5.0
|
||||
wmem_array_new@Base 3.5.0
|
||||
wmem_array_set_null_terminator@Base 3.5.0
|
||||
wmem_array_sized_new@Base 3.5.0
|
||||
wmem_array_sort@Base 3.5.0
|
||||
wmem_array_try_index@Base 3.5.0
|
||||
wmem_ascii_strdown@Base 3.5.0
|
||||
wmem_cleanup@Base 3.5.0
|
||||
wmem_destroy_allocator@Base 3.5.0
|
||||
wmem_destroy_array@Base 3.5.0
|
||||
wmem_destroy_list@Base 3.5.0
|
||||
wmem_double_hash@Base 3.5.0
|
||||
wmem_enter_scope@Base 3.5.0
|
||||
wmem_epan_scope@Base 3.5.0
|
||||
wmem_file_scope@Base 3.5.0
|
||||
wmem_free@Base 3.5.0
|
||||
wmem_free_all@Base 3.5.0
|
||||
wmem_gc@Base 3.5.0
|
||||
wmem_in_scope@Base 3.5.0
|
||||
wmem_init@Base 3.5.0
|
||||
wmem_int64_hash@Base 3.5.0
|
||||
wmem_itree_find_intervals@Base 3.5.0
|
||||
wmem_itree_insert@Base 3.5.0
|
||||
wmem_itree_is_empty@Base 3.5.0
|
||||
wmem_itree_new@Base 3.5.0
|
||||
wmem_leave_scope@Base 3.5.0
|
||||
wmem_list_append@Base 3.5.0
|
||||
wmem_list_count@Base 3.5.0
|
||||
wmem_list_find@Base 3.5.0
|
||||
wmem_list_find_custom@Base 3.5.0
|
||||
wmem_list_foreach@Base 3.5.0
|
||||
wmem_list_frame_data@Base 3.5.0
|
||||
wmem_list_frame_next@Base 3.5.0
|
||||
wmem_list_frame_prev@Base 3.5.0
|
||||
wmem_list_head@Base 3.5.0
|
||||
wmem_list_insert_sorted@Base 3.5.0
|
||||
wmem_list_new@Base 3.5.0
|
||||
wmem_list_prepend@Base 3.5.0
|
||||
wmem_list_remove@Base 3.5.0
|
||||
wmem_list_remove_frame@Base 3.5.0
|
||||
wmem_list_tail@Base 3.5.0
|
||||
wmem_map_contains@Base 3.5.0
|
||||
wmem_map_foreach@Base 3.5.0
|
||||
wmem_map_get_keys@Base 3.5.0
|
||||
wmem_map_insert@Base 3.5.0
|
||||
wmem_map_lookup@Base 3.5.0
|
||||
wmem_map_lookup_extended@Base 3.5.0
|
||||
wmem_map_new@Base 3.5.0
|
||||
wmem_map_new_autoreset@Base 3.5.0
|
||||
wmem_map_remove@Base 3.5.0
|
||||
wmem_map_size@Base 3.5.0
|
||||
wmem_map_steal@Base 3.5.0
|
||||
wmem_memdup@Base 3.5.0
|
||||
wmem_packet_scope@Base 3.5.0
|
||||
wmem_realloc@Base 3.5.0
|
||||
wmem_register_callback@Base 3.5.0
|
||||
wmem_stack_peek@Base 3.5.0
|
||||
wmem_stack_pop@Base 3.5.0
|
||||
wmem_str_hash@Base 3.5.0
|
||||
wmem_strbuf_append@Base 3.5.0
|
||||
wmem_strbuf_append_c@Base 3.5.0
|
||||
wmem_strbuf_append_len@Base 3.5.0
|
||||
wmem_strbuf_append_printf@Base 3.5.0
|
||||
wmem_strbuf_append_unichar@Base 3.5.0
|
||||
wmem_strbuf_append_vprintf@Base 3.5.0
|
||||
wmem_strbuf_finalize@Base 3.5.0
|
||||
wmem_strbuf_get_len@Base 3.5.0
|
||||
wmem_strbuf_get_str@Base 3.5.0
|
||||
wmem_strbuf_new@Base 3.5.0
|
||||
wmem_strbuf_sized_new@Base 3.5.0
|
||||
wmem_strbuf_truncate@Base 3.5.0
|
||||
wmem_strconcat@Base 3.5.0
|
||||
wmem_strdup@Base 3.5.0
|
||||
wmem_strdup_printf@Base 3.5.0
|
||||
wmem_strdup_vprintf@Base 3.5.0
|
||||
wmem_strjoin@Base 3.5.0
|
||||
wmem_strjoinv@Base 3.5.0
|
||||
wmem_strndup@Base 3.5.0
|
||||
wmem_strong_hash@Base 3.5.0
|
||||
wmem_strsplit@Base 3.5.0
|
||||
wmem_tree_count@Base 3.5.0
|
||||
wmem_tree_destroy@Base 3.5.0
|
||||
wmem_tree_foreach@Base 3.5.0
|
||||
wmem_tree_insert32@Base 3.5.0
|
||||
wmem_tree_insert32_array@Base 3.5.0
|
||||
wmem_tree_insert_string@Base 3.5.0
|
||||
wmem_tree_is_empty@Base 3.5.0
|
||||
wmem_tree_lookup32@Base 3.5.0
|
||||
wmem_tree_lookup32_array@Base 3.5.0
|
||||
wmem_tree_lookup32_array_le@Base 3.5.0
|
||||
wmem_tree_lookup32_le@Base 3.5.0
|
||||
wmem_tree_lookup_string@Base 3.5.0
|
||||
wmem_tree_new@Base 3.5.0
|
||||
wmem_tree_new_autoreset@Base 3.5.0
|
||||
wmem_tree_remove_string@Base 3.5.0
|
||||
wmem_tree_remove32@Base 3.5.0
|
||||
wmem_unregister_callback@Base 3.5.0
|
||||
write_file_binary_mode@Base 3.5.0
|
||||
ws_add_crash_info@Base 1.10.0
|
||||
ws_ascii_strnatcasecmp@Base 1.99.1
|
||||
|
|
|
@ -22,7 +22,6 @@ add_subdirectory(crypt)
|
|||
add_subdirectory(dfilter)
|
||||
add_subdirectory(dissectors)
|
||||
add_subdirectory(ftypes)
|
||||
add_subdirectory(wmem)
|
||||
|
||||
if(LUA_FOUND)
|
||||
add_subdirectory(wslua)
|
||||
|
@ -161,6 +160,8 @@ set(LIBWIRESHARK_PUBLIC_HEADERS
|
|||
uat-int.h
|
||||
unit_strings.h
|
||||
value_string.h
|
||||
wmem/wmem.h
|
||||
wmem/wmem_scopes.h
|
||||
x264_prt_id.h
|
||||
xdlc.h
|
||||
)
|
||||
|
@ -258,6 +259,7 @@ set(LIBWIRESHARK_NONGENERATED_FILES
|
|||
uat.c
|
||||
value_string.c
|
||||
unit_strings.c
|
||||
wmem/wmem_scopes.c
|
||||
xdlc.c
|
||||
protobuf-helper.c
|
||||
protobuf_lang_tree.c
|
||||
|
@ -296,7 +298,6 @@ add_library(epan
|
|||
$<TARGET_OBJECTS:dissectors>
|
||||
$<TARGET_OBJECTS:dissectors-corba>
|
||||
$<TARGET_OBJECTS:ftypes>
|
||||
$<TARGET_OBJECTS:wmem>
|
||||
$<$<BOOL:${LUA_FOUND}>:$<TARGET_OBJECTS:wslua>>
|
||||
${CMAKE_BINARY_DIR}/image/libwireshark.rc
|
||||
)
|
||||
|
|
|
@ -253,7 +253,7 @@ epan_init(register_cb cb, gpointer client_data, gboolean load_plugins)
|
|||
* invocation just in case.
|
||||
*/
|
||||
/* initialize memory allocation subsystem */
|
||||
wmem_init();
|
||||
wmem_init_scopes();
|
||||
|
||||
/* initialize the GUID to name mapping table */
|
||||
guids_init();
|
||||
|
@ -425,7 +425,7 @@ epan_cleanup(void)
|
|||
pinfo_pool_cache = NULL;
|
||||
}
|
||||
|
||||
wmem_cleanup();
|
||||
wmem_cleanup_scopes();
|
||||
}
|
||||
|
||||
struct epan_session {
|
||||
|
|
|
@ -510,13 +510,13 @@ main(int argc, char **argv)
|
|||
g_test_add_func("/oids/add/encoded", oids_test_add_encoded);
|
||||
g_test_add_func("/oids/add/string", oids_test_add_string);
|
||||
|
||||
wmem_init();
|
||||
wmem_init_scopes();
|
||||
test_scope = wmem_allocator_new(WMEM_ALLOCATOR_STRICT);
|
||||
oids_init();
|
||||
result = g_test_run();
|
||||
oids_cleanup();
|
||||
wmem_destroy_allocator(test_scope);
|
||||
wmem_cleanup();
|
||||
wmem_cleanup_scopes();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* wmem.h
|
||||
* Definitions for the Wireshark Memory Manager
|
||||
* Definitions for the EPAN Memory Manager scopes
|
||||
* Copyright 2012, Evan Huus <eapache@gmail.com>
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
|
@ -9,24 +9,12 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef __WMEM_H__
|
||||
#define __WMEM_H__
|
||||
#ifndef __EPAN_WMEM_H__
|
||||
#define __EPAN_WMEM_H__
|
||||
|
||||
#include "wmem_array.h"
|
||||
#include "wmem_core.h"
|
||||
#include "wmem_list.h"
|
||||
#include "wmem_map.h"
|
||||
#include "wmem_miscutl.h"
|
||||
#include "wmem_queue.h"
|
||||
#include "wmem_scopes.h"
|
||||
#include "wmem_stack.h"
|
||||
#include "wmem_strbuf.h"
|
||||
#include "wmem_strutl.h"
|
||||
#include "wmem_tree.h"
|
||||
#include "wmem_interval_tree.h"
|
||||
#include "wmem_user_cb.h"
|
||||
|
||||
#endif /* __WMEM_H__ */
|
||||
#endif /* __EPAN_WMEM_H__ */
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
|
|
|
@ -11,10 +11,9 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "wmem-int.h"
|
||||
#include "wmem_core.h"
|
||||
#include "wmem_scopes.h"
|
||||
#include "wmem_allocator.h"
|
||||
|
||||
#include <wsutil/ws_assert.h>
|
||||
|
||||
/* One of the supposed benefits of wmem over the old emem was going to be that
|
||||
* the scoping of the various memory pools would be obvious, since they would
|
||||
|
@ -46,7 +45,7 @@ static wmem_allocator_t *epan_scope = NULL;
|
|||
wmem_allocator_t *
|
||||
wmem_packet_scope(void)
|
||||
{
|
||||
ASSERT(packet_scope);
|
||||
ws_assert(packet_scope);
|
||||
|
||||
return packet_scope;
|
||||
}
|
||||
|
@ -54,21 +53,20 @@ wmem_packet_scope(void)
|
|||
void
|
||||
wmem_enter_packet_scope(void)
|
||||
{
|
||||
ASSERT(packet_scope);
|
||||
ASSERT(file_scope->in_scope);
|
||||
ASSERT(!packet_scope->in_scope);
|
||||
ws_assert(packet_scope);
|
||||
ws_assert(wmem_in_scope(file_scope));
|
||||
ws_assert(!wmem_in_scope(packet_scope));
|
||||
|
||||
packet_scope->in_scope = TRUE;
|
||||
wmem_enter_scope(packet_scope);
|
||||
}
|
||||
|
||||
void
|
||||
wmem_leave_packet_scope(void)
|
||||
{
|
||||
ASSERT(packet_scope);
|
||||
ASSERT(packet_scope->in_scope);
|
||||
ws_assert(packet_scope);
|
||||
ws_assert(wmem_in_scope(packet_scope));
|
||||
|
||||
wmem_free_all(packet_scope);
|
||||
packet_scope->in_scope = FALSE;
|
||||
wmem_leave_scope(packet_scope);
|
||||
}
|
||||
|
||||
/* File Scope */
|
||||
|
@ -76,7 +74,7 @@ wmem_leave_packet_scope(void)
|
|||
wmem_allocator_t *
|
||||
wmem_file_scope(void)
|
||||
{
|
||||
ASSERT(file_scope);
|
||||
ws_assert(file_scope);
|
||||
|
||||
return file_scope;
|
||||
}
|
||||
|
@ -84,21 +82,20 @@ wmem_file_scope(void)
|
|||
void
|
||||
wmem_enter_file_scope(void)
|
||||
{
|
||||
ASSERT(file_scope);
|
||||
ASSERT(!file_scope->in_scope);
|
||||
ws_assert(file_scope);
|
||||
ws_assert(!wmem_in_scope(file_scope));
|
||||
|
||||
file_scope->in_scope = TRUE;
|
||||
wmem_enter_scope(file_scope);
|
||||
}
|
||||
|
||||
void
|
||||
wmem_leave_file_scope(void)
|
||||
{
|
||||
ASSERT(file_scope);
|
||||
ASSERT(file_scope->in_scope);
|
||||
ASSERT(!packet_scope->in_scope);
|
||||
ws_assert(file_scope);
|
||||
ws_assert(wmem_in_scope(file_scope));
|
||||
ws_assert(!wmem_in_scope(packet_scope));
|
||||
|
||||
wmem_free_all(file_scope);
|
||||
file_scope->in_scope = FALSE;
|
||||
wmem_leave_scope(file_scope);
|
||||
|
||||
/* this seems like a good time to do garbage collection */
|
||||
wmem_gc(file_scope);
|
||||
|
@ -110,7 +107,7 @@ wmem_leave_file_scope(void)
|
|||
wmem_allocator_t *
|
||||
wmem_epan_scope(void)
|
||||
{
|
||||
ASSERT(epan_scope);
|
||||
ws_assert(epan_scope);
|
||||
|
||||
return epan_scope;
|
||||
}
|
||||
|
@ -120,33 +117,37 @@ wmem_epan_scope(void)
|
|||
void
|
||||
wmem_init_scopes(void)
|
||||
{
|
||||
ASSERT(packet_scope == NULL);
|
||||
ASSERT(file_scope == NULL);
|
||||
ASSERT(epan_scope == NULL);
|
||||
ws_assert(packet_scope == NULL);
|
||||
ws_assert(file_scope == NULL);
|
||||
ws_assert(epan_scope == NULL);
|
||||
|
||||
wmem_init();
|
||||
|
||||
packet_scope = wmem_allocator_new(WMEM_ALLOCATOR_BLOCK_FAST);
|
||||
file_scope = wmem_allocator_new(WMEM_ALLOCATOR_BLOCK);
|
||||
epan_scope = wmem_allocator_new(WMEM_ALLOCATOR_BLOCK);
|
||||
|
||||
/* Scopes are initialized to TRUE by default on creation */
|
||||
packet_scope->in_scope = FALSE;
|
||||
file_scope->in_scope = FALSE;
|
||||
wmem_leave_scope(packet_scope);
|
||||
wmem_leave_scope(file_scope);
|
||||
}
|
||||
|
||||
void
|
||||
wmem_cleanup_scopes(void)
|
||||
{
|
||||
ASSERT(packet_scope);
|
||||
ASSERT(file_scope);
|
||||
ASSERT(epan_scope);
|
||||
ws_assert(packet_scope);
|
||||
ws_assert(file_scope);
|
||||
ws_assert(epan_scope);
|
||||
|
||||
ASSERT(packet_scope->in_scope == FALSE);
|
||||
ASSERT(file_scope->in_scope == FALSE);
|
||||
ws_assert(!wmem_in_scope(packet_scope));
|
||||
ws_assert(!wmem_in_scope(file_scope));
|
||||
|
||||
wmem_destroy_allocator(packet_scope);
|
||||
wmem_destroy_allocator(file_scope);
|
||||
wmem_destroy_allocator(epan_scope);
|
||||
|
||||
wmem_cleanup();
|
||||
|
||||
packet_scope = NULL;
|
||||
file_scope = NULL;
|
||||
epan_scope = NULL;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef __WMEM_SCOPES_H__
|
||||
#define __WMEM_SCOPES_H__
|
||||
|
||||
#include "wmem_core.h"
|
||||
#include <wsutil/wmem/wmem.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -54,11 +54,11 @@ wmem_leave_file_scope(void);
|
|||
|
||||
/* Scope Management */
|
||||
|
||||
WS_DLL_LOCAL
|
||||
WS_DLL_PUBLIC
|
||||
void
|
||||
wmem_init_scopes(void);
|
||||
|
||||
WS_DLL_LOCAL
|
||||
WS_DLL_PUBLIC
|
||||
void
|
||||
wmem_cleanup_scopes(void);
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ add_definitions(-DPLUGIN_DIR=\"${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_LIBDIR}\
|
|||
add_definitions(-DEXTCAP_DIR=\"${CMAKE_INSTALL_PREFIX}/${EXTCAP_INSTALL_LIBDIR}\")
|
||||
add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}\")
|
||||
|
||||
add_subdirectory(wmem)
|
||||
|
||||
set(WSUTIL_PUBLIC_HEADERS
|
||||
802_11-utils.h
|
||||
adler32.h
|
||||
|
@ -248,6 +250,7 @@ endif()
|
|||
|
||||
add_library(wsutil
|
||||
${WSUTIL_FILES}
|
||||
$<TARGET_OBJECTS:wmem>
|
||||
${CMAKE_BINARY_DIR}/image/libwsutil.rc
|
||||
)
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ set(WMEM_PUBLIC_HEADERS
|
|||
wmem_map.h
|
||||
wmem_miscutl.h
|
||||
wmem_queue.h
|
||||
wmem_scopes.h
|
||||
wmem_stack.h
|
||||
wmem_strbuf.h
|
||||
wmem_strutl.h
|
||||
|
@ -48,7 +47,6 @@ set(WMEM_FILES
|
|||
wmem_list.c
|
||||
wmem_map.c
|
||||
wmem_miscutl.c
|
||||
wmem_scopes.c
|
||||
wmem_stack.c
|
||||
wmem_strbuf.c
|
||||
wmem_strutl.c
|
||||
|
@ -77,7 +75,7 @@ target_include_directories(wmem
|
|||
)
|
||||
|
||||
set_target_properties(wmem PROPERTIES
|
||||
FOLDER "Libs/epan/wmem"
|
||||
FOLDER "Libs/wsutil/wmem"
|
||||
COMPILE_DEFINITIONS "WS_BUILD_DLL"
|
||||
)
|
||||
|
||||
|
@ -92,7 +90,7 @@ set_target_properties(wmem_test PROPERTIES
|
|||
)
|
||||
|
||||
install(FILES ${WMEM_PUBLIC_HEADERS}
|
||||
DESTINATION "${PROJECT_INSTALL_INCLUDEDIR}/epan/wmem"
|
||||
DESTINATION "${PROJECT_INSTALL_INCLUDEDIR}/wsutil/wmem"
|
||||
)
|
||||
|
||||
CHECKAPI(
|
|
@ -0,0 +1,41 @@
|
|||
/* wmem.h
|
||||
* Definitions for the Wireshark Memory Manager
|
||||
* Copyright 2012, Evan Huus <eapache@gmail.com>
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef __WMEM_H__
|
||||
#define __WMEM_H__
|
||||
|
||||
#include "wmem_array.h"
|
||||
#include "wmem_core.h"
|
||||
#include "wmem_list.h"
|
||||
#include "wmem_map.h"
|
||||
#include "wmem_miscutl.h"
|
||||
#include "wmem_queue.h"
|
||||
#include "wmem_stack.h"
|
||||
#include "wmem_strbuf.h"
|
||||
#include "wmem_strutl.h"
|
||||
#include "wmem_tree.h"
|
||||
#include "wmem_interval_tree.h"
|
||||
#include "wmem_user_cb.h"
|
||||
|
||||
#endif /* __WMEM_H__ */
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#include "wmem-int.h"
|
||||
#include "wmem_core.h"
|
||||
#include "wmem_scopes.h"
|
||||
#include "wmem_map_int.h"
|
||||
#include "wmem_user_cb_int.h"
|
||||
#include "wmem_allocator.h"
|
||||
|
@ -199,16 +198,34 @@ wmem_init(void)
|
|||
}
|
||||
}
|
||||
|
||||
wmem_init_scopes();
|
||||
wmem_init_hashing();
|
||||
}
|
||||
|
||||
void
|
||||
wmem_cleanup(void)
|
||||
{
|
||||
wmem_cleanup_scopes();
|
||||
}
|
||||
|
||||
void
|
||||
wmem_enter_scope(wmem_allocator_t *allocator)
|
||||
{
|
||||
allocator->in_scope = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
wmem_leave_scope(wmem_allocator_t *allocator)
|
||||
{
|
||||
wmem_free_all(allocator);
|
||||
allocator->in_scope = FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
wmem_in_scope(wmem_allocator_t *allocator)
|
||||
{
|
||||
return allocator->in_scope;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
|
@ -210,6 +210,18 @@ WS_DLL_PUBLIC
|
|||
void
|
||||
wmem_cleanup(void);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
void
|
||||
wmem_enter_scope(wmem_allocator_t *allocator);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
void
|
||||
wmem_leave_scope(wmem_allocator_t *allocator);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
gboolean
|
||||
wmem_in_scope(wmem_allocator_t *allocator);
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
Loading…
Reference in New Issue