Commit Graph

38 Commits

Author SHA1 Message Date
Michael Mann b7d6cca4ae Add wmem_tree_destroy
Allows the cleanup of NULL scoped wmem trees

Change-Id: I7c49a224ca7e2f7ddfe0e38d3ea0e79aa2cb057c
Reviewed-on: https://code.wireshark.org/review/20382
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
2017-03-05 03:39:00 +00:00
Michael Mann 9b4f325132 Add wmem_tree_count.
There are cases where wmem_tree needs to know its number of nodes.

Change-Id: I6411cf4275fd4d85a1d76382e1922d236be3b176
Reviewed-on: https://code.wireshark.org/review/20005
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-04 21:53:25 +00:00
Michael Mann cd38552259 Add wmem_tree_remove32
Change-Id: Ic79fd0a2a13341dd7ba563cf3a056c51e9d16960
Reviewed-on: https://code.wireshark.org/review/20037
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-09 22:02:25 +00:00
Jaap Keuter 4ff9bddc46 wmem: fix rb-tree data printer feed
When using a data printer for the red/black tree it is fed with the
nodes of the tree. But nodes can be either subtree or data nodes.
Don't feed the subtree nodes to the data printer. The data printer can't
recognize it as such, can't handle it, or worse, could break stuff.

Change-Id: Ibbc1311d901c0d0c52e710f951dd53620f2c3d0f
Reviewed-on: https://code.wireshark.org/review/19652
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-01-22 10:40:34 +00:00
Michael Mann e302d9fe4d Remove checkAPI warnings from wmem.
printf and g_warning are not allowed in epan or its subdirectories

Change-Id: I4c07a7258f4c9566384bef93af35c350b5c88758
Reviewed-on: https://code.wireshark.org/review/16801
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-08-01 04:21:22 +00:00
Matthieu Coudron bd08ab920d Introduces augmented interval trees
Interval trees (wmem_itree_t) are implemented as an extension of wmem_tree with a
guint64-based range as the key.
This is useful for instance in MPTCP analysis, to look for packets
matching a range defined by a mapping across TCP subflows.

Change-Id: Iea706d44fe975e390a4191ad0257ef37d5c71525
Reviewed-on: https://code.wireshark.org/review/11714
Reviewed-by: Evan Huus <eapache@gmail.com>
Petri-Dish: Evan Huus <eapache@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-24 23:02:09 +00:00
Matthieu Coudron c2afc9edec Change prototype of callbacks passed to wmem_tree_foreach so that they
accept the node key as a first parameter.

wmem_tree accepts all sort of keys (strings, integers, soon ranges),
thus it is of interest for various purposes (testing, greedy search) to
know the key of the node.

Change-Id: Ie748b917bef91f0b1ba8cce15bd1b471922641dc
Reviewed-on: https://code.wireshark.org/review/11683
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-11 00:22:37 +00:00
Stig Bjørlykke 58ec64c36e wmem: Fix wmem_tree_remove_string
Always set is_removed when insert data in a node.

Change-Id: I8fb50932a369e3f4fe8a1f743462683fff705cc2
Reviewed-on: https://code.wireshark.org/review/9978
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-08-11 19:55:01 +00:00
Stig Bjørlykke d6c6b0899d wmem: Mark removed strings with is_removed
This will allow integer value 0 again.

Change-Id: Ibfa4249ea8b887971d3b3214ad9e4d095d20d155
Reviewed-on: https://code.wireshark.org/review/9973
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-08-11 14:15:49 +00:00
Stig Bjørlykke ecc4f756bd Added Reload Lua plugins.
This is initial support for reloading Lua plugins without
restarting the application.

Still todo:
- Deregister FileHandlers
- Support deregister ProtoField with existing abbrev (same_name_hfinfo)
- Add a progress dialog when reloading many plugins
- Search for memory leakages in wslua functions

Change-Id: I48870d8741251705ca15ffe1068613fcb0cb18c1
Reviewed-on: https://code.wireshark.org/review/5028
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-08-11 12:09:07 +00:00
Evan Huus b855a9fa4d wmem: permit lookups in NULL trees (oops)
Change-Id: I222b95b48b7ac8debbd717b32dd471742222c16b
Reviewed-on: https://code.wireshark.org/review/9177
Reviewed-by: Evan Huus <eapache@gmail.com>
2015-06-26 18:40:46 +00:00
Evan Huus 66c738817c wmem: convert string trees to single-layer
The whole radix tree thing is kind of neat (and may even be more performant for
short strings?) but it's really confusing to reason about and is terribly
inefficient for long strings.

Ping-Bug: 9078
Change-Id: I1bd333918a6e557801e82f4553d386120138065e
Reviewed-on: https://code.wireshark.org/review/9165
Reviewed-by: Evan Huus <eapache@gmail.com>
2015-06-26 18:35:47 +00:00
Evan Huus d81ba670a1 wmem: bubble up key type change another function
Follow-up to gb679e2a.

Change-Id: I6cc168c3f3a6e1c8ce7bfa9344255acd3c8a7d20
Reviewed-on: https://code.wireshark.org/review/9164
Reviewed-by: Evan Huus <eapache@gmail.com>
2015-06-25 22:26:12 +00:00
Evan Huus b679e2aab5 wmem: convert tree key to void*
Rather than forcing everything to live in guint32. We still use guints for now
via the G_POINTER_TO_UINT and vice-versa, but this paves the way in future for
custom comparison functions which will make e.g. string trees far more
efficient for long strings.

Change-Id: Ibb15400f74761ae295948507df8d2e022f2ebb05
Reviewed-on: https://code.wireshark.org/review/9138
Reviewed-by: Evan Huus <eapache@gmail.com>
2015-06-25 18:14:37 +00:00
Guy Harris 2b6c267a57 Eliminate use of ctype.h routines.
That way, we don't do locale-sensitive case-insensitivity (yes, the
locale can affect case-mapping - in a Turkish locale, "I" isn't the
upper-case version of "i", for example).

Change-Id: I5f7663e85160558ff3769617f924e45049c9c384
Reviewed-on: https://code.wireshark.org/review/4843
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-19 22:45:27 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Anders Broman 5fbfa6c351 Fix [-Wmissing-prototypes]
svn path=/trunk/; revision=54280
2013-12-20 06:30:13 +00:00
Evan Huus dc0b7253e4 Don't assert that the key to a wmem tree operation is short. If XMPP wants to
use a 1500-byte string as a key, so be it. It will be slow, but at least it will
work.

Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9078

svn path=/trunk/; revision=52261
2013-09-28 23:45:18 +00:00
Evan Huus 3c1e67c22d Send all alloc and free calls within wmem through wmem_alloc and wmem_free with
a NULL allocator. This gives us a single, central place to handle out-of-memory
errors (by, for example, throwing an exception) for basically all of epan.

The only remaining glib memory that is directly allocated is for the hash tables
used by the simple and strict allocators.

svn path=/trunk/; revision=51627
2013-09-01 13:37:38 +00:00
Guy Harris e8f42c6b48 Include config.h first; it defines _FILE_OFFSET_BITS, and if some system
header later causes it to be redefined - as happens on my Solaris 11
virtual machine - we get a redefinition warning, which gets treated as
an error.

svn path=/trunk/; revision=51344
2013-08-14 00:31:14 +00:00
Evan Huus 8fafa9b758 Add wmem_tree_is_empty(). Also permit lookups on a NULL tree for compatibility
with emem.

svn path=/trunk/; revision=51045
2013-07-31 01:48:47 +00:00
Chris Maynard 1c19a0d61e Fix warnings: format '%blah' expects argument of type 'foo', but argument 'i' has type 'bar' [-Wformat].
svn path=/trunk/; revision=50639
2013-07-15 21:22:34 +00:00
Evan Huus ffe6d9c4d6 Misc little cleanups to wmem tree (comments, whitespace, assertions)
svn path=/trunk/; revision=50182
2013-06-27 03:01:53 +00:00
Evan Huus bfa8d9af75 Make assertions in tree lookup more useful and fix formatting.
Should help debugging https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8833

svn path=/trunk/; revision=50115
2013-06-22 21:00:36 +00:00
Evan Huus da6d99e2c9 Refactor insert32 to use lookup_or_insert32 with the right flags.
svn path=/trunk/; revision=50013
2013-06-18 19:55:29 +00:00
Evan Huus 4313d778f0 Refactor lookup_or_insert32 to remove a bunch of continue and break statements
as well as a confusing while(TRUE).

svn path=/trunk/; revision=50012
2013-06-18 19:43:18 +00:00
Evan Huus 8610601f60 Simplify node structure. Use a boolean for whether or not it's a subtree, and an
enum for the color (red/black). Don't use bitfields since they don't save us
much (if anything) in terms of space and don't nest the fields in their own
anonymous struct.

svn path=/trunk/; revision=50011
2013-06-18 19:32:40 +00:00
Evan Huus 02752f3161 Factor function for node creation out and use it in several places.
svn path=/trunk/; revision=50010
2013-06-18 19:19:21 +00:00
Evan Huus 115eb9c727 Factor common code for red-black tree array lookups into a helper function and
use it for both direct lookups and less-than-or-equal-to lookups.

svn path=/trunk/; revision=50008
2013-06-18 18:57:28 +00:00
Evan Huus 7fd970ac45 Remove wmem_tree_create_subtree, it does nothing we can't do with
wmem_tree_new.

svn path=/trunk/; revision=50007
2013-06-18 17:48:04 +00:00
Evan Huus d0c1d89cd6 Factor string-packing code into a common function to use in both insert_string
and lookup_string.

svn path=/trunk/; revision=50006
2013-06-18 17:39:15 +00:00
Evan Huus 7c99d55773 Re-port a bunch of the red-black tree code from wmem with fewer modifications,
and enable the tests.

Lesson: make it work, *then* refactor it into sanity.

svn path=/trunk/; revision=50002
2013-06-18 05:31:12 +00:00
Evan Huus 5c027c2590 Extract some common code for array lookups, and replace some DISSECTOR
assertions with regular glib assertions - there's no guarantee that wmem code
will always be run from within a dissector.

svn path=/trunk/; revision=49993
2013-06-17 22:51:50 +00:00
Evan Huus fd22c548f5 Much smarter handling of autoreset trees.
svn path=/trunk/; revision=49970
2013-06-17 00:08:44 +00:00
Evan Huus 55264582be More callback tweaks, to permit unregistering a callback from the same place
it was originally registered.

svn path=/trunk/; revision=49969
2013-06-16 22:37:55 +00:00
Evan Huus 88c5b2e892 Rework the user callback code a bit to make it saner to use with the auto-reset
trees.

svn path=/trunk/; revision=49966
2013-06-16 22:07:24 +00:00
Evan Huus d0fb6aca01 Simplify the tree code slightly - just don't call the transform function
if it's NULL, meaning we don't need to define an identity callback.

svn path=/trunk/; revision=49962
2013-06-16 15:17:53 +00:00
Evan Huus 6fd601bc3b Most of a red-black tree implementation for wmem, based heavily on the emem
version.

One plane trip's worth of work.

svn path=/trunk/; revision=49945
2013-06-15 10:40:56 +00:00