Commit Graph

15 Commits

Author SHA1 Message Date
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