Wireshark mailing list archives
Re: RFD: The Future of Memory Management in Wireshark
From: Jakub Zawadzki <darkjames-ws () darkjames pl>
Date: Mon, 29 Oct 2012 00:26:16 +0100
On Sun, Oct 28, 2012 at 10:12:41AM -0400, Evan Huus wrote:
We might be able to fake the proper scoping using thread-local globals if we wrap everything in functions that assert the state of a dissection. Something like: __thread wmem_allocator_t *packet_scope; __thread gboolean packet_in_scope = FALSE;
Just a note before commiting: __thread is GCC extension, MVSC has got __declspec(thread) and C11 has got _Thread_local. So to be portable we must use glib GStaticPrivate.
wmem_allocator_t * wmem_packet_scope(void) { g_assert(packet_in_scope); return packet_scope; } void wmem_start_packet_scope(void) { g_assert(!packet_in_scope); packet_in_scope = TRUE; } void wmem_stop_packet_scope(void) { g_assert(packet_in_scope); packet_in_scope = FALSE; wmem_free_all(packet_scope); } Invalid accesses would still compile, but at least they would throw an assertion as soon as the code path was hit. Thoughts on something like this?
I'm not sure if you want to replace all ep_ pool with packet_scope pool, but if yes what kind of memory you want to use in GUI, or for error messages in epan/dfilter/? glib allocator? Cheers, Kuba. ___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org> Archives: http://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- Re: RFD: The Future of Memory Management in Wireshark, (continued)
- Re: RFD: The Future of Memory Management in Wireshark Evan Huus (Oct 26)
- Re: RFD: The Future of Memory Management in Wireshark Sébastien Tandel (Oct 26)
- Re: RFD: The Future of Memory Management in Wireshark Jeff Morriss (Oct 25)
- Re: RFD: The Future of Memory Management in Wireshark Evan Huus (Oct 25)
- Re: RFD: The Future of Memory Management in Wireshark Jeff Morriss (Oct 25)
- Re: RFD: The Future of Memory Management in Wireshark Evan Huus (Oct 25)
- Re: RFD: The Future of Memory Management in Wireshark Pascal Quantin (Oct 25)
- Re: RFD: The Future of Memory Management in Wireshark Dirk Jagdmann (Oct 27)
- Re: RFD: The Future of Memory Management in Wireshark Evan Huus (Oct 27)
- Re: RFD: The Future of Memory Management in Wireshark Evan Huus (Oct 28)
- Re: RFD: The Future of Memory Management in Wireshark Jakub Zawadzki (Oct 28)
- Re: RFD: The Future of Memory Management in Wireshark Evan Huus (Oct 28)
- Re: RFD: The Future of Memory Management in Wireshark Jakub Zawadzki (Oct 29)
- Re: RFD: The Future of Memory Management in Wireshark Evan Huus (Oct 29)
- Re: RFD: The Future of Memory Management in Wireshark Evan Huus (Oct 25)