Commit Graph

18 Commits

Author SHA1 Message Date
Gerald Combs 095d897381 wmem: Use better terminology.
The scopes used by wmem_map_new_autoreset and wmem_tree_new_autoreset
store the metadata and data for each structure. Use those terms instead
of "master" and "slave".

Change-Id: I3b7c958b4caf3a1245e680f5ca960431b75ad5be
Reviewed-on: https://code.wireshark.org/review/37398
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-08 05:08:22 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
chinarulezzz ec0f8e6c36 fix missing parentheses in 'if' statement
Change-Id: I47f8566c4410d6aac1111b35fff3b044c14bc70b
Reviewed-on: https://code.wireshark.org/review/27079
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-03 04:09:42 +00:00
Guy Harris d4ef22db8f Make sure CAPACITY() doesn't shift the 1 out of range.
Make the 1 we shift left the size of a size_t, so it'll only go out of
range if the result couldn't possibly fit in a size_t.  (That should
also make the object of the shift unsigned, which may squelch some other
complaints.)

Not that the map is *likely* to be bigger than 4GB, but it should
squelch some complaints from Visual Studio Code Analysis.

Change-Id: I489bfe6b1d9d4329c267936d9106dbba4388c492
Reviewed-on: https://code.wireshark.org/review/26163
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-28 02:52:03 +00:00
Dario Lombardo fc082fa2a9 wmem: use SPDX identifiers.
Change-Id: Iad9a7a8a26bc6a7189a4578dfbcec1c2b3cc376e
Reviewed-on: https://code.wireshark.org/review/25692
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 19:29:02 +00:00
Moshe Kaplan b13678fd37 Added wmem_map_contains and wmem_map_lookup_extended
Change-Id: I2943c67238fb913258f0f1f15df968c17b1ea002
Reviewed-on: https://code.wireshark.org/review/25626
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-07 05:21:20 +00:00
Michael Mann f8b69fb349 Add wmem_map_get_keys.
Mimic functionality of g_hash_table_get_keys

Change-Id: I7702854ed771a5b3bf7ea5295a67c42f0f477cdf
Reviewed-on: https://code.wireshark.org/review/20039
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-02-09 22:03:10 +00:00
Michael Mann e3128d9806 Add wmem_map_steal
Mimic functionality of g_hash_table_steal

Change-Id: Iaf4aeef951b60934569143b2d119f782aeefe380
Reviewed-on: https://code.wireshark.org/review/20038
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-09 22:03:01 +00:00
Michael Mann 120a1ebb22 wmem: Delay creation of map table until its needed
wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), ...)
doesn't have "file" scope ready at startup to create hash table
and will assert.

Change-Id: I3437f45ef42bf8635e4d504cf073fc3fb0c9a8cd
Reviewed-on: https://code.wireshark.org/review/19825
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
2017-01-28 18:48:33 +00:00
Michael Mann 6cff5c6776 Add wmem_map_new_autoreset
This can be used similarly to wmem_tree_new_autoreset for hash tables that need
reset after capture file change.

Change-Id: I3a2f0b0a0cad3eca46266523c594d3d7aac17489
Reviewed-on: https://code.wireshark.org/review/19794
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-01-28 12:59:52 +00:00
Michael Mann 6d8ea38773 wmem_map.c: Address some VS Code Analysis warnings.
size_t can vary on size, so you can't always mix it with guint.

Change-Id: I7e2ea3a990dd4df99422f6113aa3ae53dbf2bc4f
Reviewed-on: https://code.wireshark.org/review/16501
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-16 19:46:05 +00:00
Dario Lombardo fc3885fd51 wmem: add wmem_map_size().
Change-Id: I3acca7939466a4436e23bcf828ef94f927ce8b76
Reviewed-on: https://code.wireshark.org/review/15042
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-22 04:34:45 +00:00
Dario Lombardo fe75c87575 wmem: add foreach function to wmem_map.
Makes wmem_map more similar to g_hash.

Change-Id: Ia17a19ab0be8e07fbb64801d54db2ba8217a7fea
Reviewed-on: https://code.wireshark.org/review/15020
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-22 04:33:58 +00:00
Alexis La Goutte 3adbd93771 Fix warning: no previous prototype for ... [-Wmissing-prototypes]
Change-Id: I59e744d905a0a13eea4ff649a984b2ed9f1f51e7
Reviewed-on: https://code.wireshark.org/review/3697
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-08-18 13:13:43 +00:00
Gerald Combs b60ccf6dae Fix an extraneous parentheses warning.
"if (G_UNLIKELY(...))" triggers an extraneous parentheses warning when
compiling with XCode's clang-500.2.75. From looking at the macro
definition we *should* be able to get rid of the outer parentheses
everywhere.

Change-Id: I710e1cc391e1167c1243c4ddb032f2831f0a9498
Reviewed-on: https://code.wireshark.org/review/1432
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-04-29 15:35:29 +00:00
Michael Mann 98ed927290 Fix rare case of wmem map being O(n)
For 'x' equal to 0, HASH() macro also returns 0 which makes wmem map O(n).
When random generator will return 0 just use 1.

Change-Id: If484091352a719aea27135a705d37ff4c184a13b
Reviewed-on: https://code.wireshark.org/review/1387
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-04-27 21:55:53 +00:00
Evan Huus f0e77aa366 Add a cast to satisfy mac buildbot.
Change-Id: I625b025d3f8a57812512497c6104977ae5d10232
Reviewed-on: https://code.wireshark.org/review/1298
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-23 12:58:53 +00:00
Evan Huus 9ba4c6e091 Hash map implementation for wmem.
This has two expected uses:
- Many current users of wmem_tree don't actually need the predecessor lookup
  it provides (the lookup_le function family). A hash map provides straight
  insertion and lookup much more efficiently than a wmem_tree when predecessor
  lookup isn't needed.

- Many current users of glib's hash table and hash functions use untrusted data
  for keys, making them vulnerable to algorithmic complexity attacks. Care has
  been taken to make this implementation secure against such attacks, so it
  should be used whenever data is untrusted.

In my benchmarks it is measurably slower than GHashTable, but not excessively
so. Given the additional security it provides this seems like a reasonable
trade-off (and it is still faster than a wmem_tree).

Change-Id: I2d67a0d06029f14c153eaa42d5cfc774aefd9918
Reviewed-on: https://code.wireshark.org/review/1272
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-23 12:42:26 +00:00