diff options
author | Bill Meier <wmeier@newsguy.com> | 2012-08-24 20:44:33 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2012-08-24 20:44:33 +0000 |
commit | 0035a9076b4b5c8a14ffa67934696623a3c4bf19 (patch) | |
tree | 75587af9c72567e6d9e94fbdaec684d1b526490c /epan/value_string.c | |
parent | 7d891022e647144f729fc55a62053a5c92bd02e8 (diff) |
Force extended value string linear search (not binary search) in one case:
Fixed: { -2, -1, 0, 1, 3} (note gap) used a binary search (which would fail);
Note: { -2, -1, 0, 1, 2 ,3 } (no gap) allowed; will still do a direct access;
Also: Add a comment to README.developer extended value string section.
svn path=/trunk/; revision=44659
Diffstat (limited to 'epan/value_string.c')
-rw-r--r-- | epan/value_string.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/epan/value_string.c b/epan/value_string.c index 43453f1f14..f48b3155ff 100644 --- a/epan/value_string.c +++ b/epan/value_string.c @@ -285,6 +285,20 @@ _match_strval_ext_init(const guint32 val, const value_string_ext *a_vse) * 1 Binary search, the values MUST be in numerical order. * 2 The value used as an index(the value string MUST have all values between first and last defined in numerical order) */ + +/* Note: The value_string 'value' is *unsigned*. + * + * Special case: + * { -3, -2, -1, 0, 1, 2 } will be treated as "ascending ordered" (altho not really such) + * thus allowing as a 'direct' search. + * + * Note: + * { -3, -2, 0, 1, 2 } and { -3, -2, -1, 0, 2 } will both be considered as "out-of-order with gaps" + * thus requiring a 'linear' search. + * { 0, 1, 2, -3, -2 } and { 0, 2, -3, -2, -1 } will be considered "ascending ordered with gaps" + * thus allowing a 'binary' search. + */ + enum { VS_SEARCH = 0, VS_BIN_TREE, VS_INDEX } type = VS_INDEX; guint32 prev_value; @@ -303,7 +317,8 @@ _match_strval_ext_init(const guint32 val, const value_string_ext *a_vse) type = VS_BIN_TREE; } /* XXX: Should check for dups ?? */ - if ((type == VS_BIN_TREE) && (prev_value > vs_p[i].value)) { + if ((type == VS_BIN_TREE) && + ((prev_value > vs_p[i].value) || (first_value > vs_p[i].value))) { type = VS_SEARCH; break; } |