aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wmem
AgeCommit message (Collapse)AuthorFilesLines
2015-12-04Adds wmem_list_find functionMatthieu Coudron2-0/+20
Change-Id: I72162210b830a57978e108032d75d8c54f17d16b Reviewed-on: https://code.wireshark.org/review/12387 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: Michael Mann <mmann78@netscape.net>
2015-11-25wmem: add initializer (CID 1340194).Dario Lombardo1-3/+1
Change-Id: I7b3d7a95af213a198b62c1475ba2125f8fe37ee6 Reviewed-on: https://code.wireshark.org/review/12142 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Evan Huus <eapache@gmail.com>
2015-11-25Print guint64's with G_GUINT64_FORMAT.Guy Harris1-1/+1
There is no guarantee that they will be long's, and thus no guarantee that they can be printed with "%lu". Change-Id: I5c2ff844a1024332f01dec58489a2d304ba4e7ce Reviewed-on: https://code.wireshark.org/review/12135 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-25No declarations in the middle of code.Guy Harris1-1/+1
We crank up pedantic warnings enough that this provokes "warning: ISO C90 forbids mixed declarations and code" on the OS X 10.5 buildbot. Change-Id: Ic3962f20d85e3ed003b84b298f83d12c3ae25ea1 Reviewed-on: https://code.wireshark.org/review/12120 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-24Avoid colliding definitions of wmem_tree_t.Guy Harris1-4/+1
Change-Id: I643eae3c35f96591770ab03ce44a85c806f17e1c Reviewed-on: https://code.wireshark.org/review/12119 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-24Introduces augmented interval treesMatthieu Coudron8-61/+591
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-11Change prototype of callbacks passed to wmem_tree_foreach so that theyMatthieu Coudron3-3/+3
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-08-11wmem: Fix wmem_tree_remove_stringStig Bjørlykke1-3/+1
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-11wmem: Mark removed strings with is_removedStig Bjørlykke1-2/+7
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-11Added Reload Lua plugins.Stig Bjørlykke2-2/+21
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-07-17wmem: don't remove tiny blocks from the recyclerEvan Huus1-1/+1
They were never put in it in the first place because they can't hold the necessary pointers. Bug: 11373 Change-Id: I9e2ec76850929b5ac86e6f7a344d70f56ad3911c Reviewed-on: https://code.wireshark.org/review/9672 Reviewed-by: Evan Huus <eapache@gmail.com>
2015-07-04store tcp/udp port names in epan scopeEvan Huus1-1/+1
This causes them to be freed on shutdown, cleaning up ~800KB of "reachable" memory according to valgrind. The fact that we even need to construct these as value_strings is questionable IMHO, but that's a problem for a later date. Switch epan_scope to the BLOCK allocator now that we're using it for so much more, this gives a small but measurable increase in startup time. Change-Id: I187460b769e28da3c6629abac1d9196727ae7dde Reviewed-on: https://code.wireshark.org/review/9483 Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Evan Huus <eapache@gmail.com>
2015-06-26wmem: permit lookups in NULL trees (oops)Evan Huus1-1/+7
Change-Id: I222b95b48b7ac8debbd717b32dd471742222c16b Reviewed-on: https://code.wireshark.org/review/9177 Reviewed-by: Evan Huus <eapache@gmail.com>
2015-06-26wmem: convert string trees to single-layerEvan Huus1-78/+92
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-25wmem: bubble up key type change another functionEvan Huus1-5/+5
Follow-up to gb679e2a. Change-Id: I6cc168c3f3a6e1c8ce7bfa9344255acd3c8a7d20 Reviewed-on: https://code.wireshark.org/review/9164 Reviewed-by: Evan Huus <eapache@gmail.com>
2015-06-25wmem: convert tree key to void*Evan Huus1-17/+16
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-03-13Add a test-programs target everywhere.Gerald Combs2-2/+6
Add a "test-programs" target to each toolchain which builds each unit test executable. "test-programs" must now be built before running the unit test suite. Change-Id: I9317a1e305d987f244c4bd8b4a7f05d11fed7090 Reviewed-on: https://code.wireshark.org/review/7673 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-02-08WMEM (allocator): fix warning: redeclaration of already-defined enum ↵Alexis La Goutte1-1/+0
'_wmem_allocator_type_t' is a GNU extension [-Wgnu-redeclared-enum] Change-Id: Ied0428324c14f248bf6857fd288b4fb5d4591230 Reviewed-on: https://code.wireshark.org/review/7033 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-25Lua can free tvbuffs too earlyHadriel Kaplan1-1/+1
Lua-created tvbuffs should be kept around for the duration of pinfo's lifetime, instead of only for the duration of frame dissection. So instead of using the frame dissector's frame_end_routine, we'll register a callback to wmem for pinfo pool's allocator. Bug: 10888 Change-Id: I3e9db671c3f2a7cab9e258aca17f3be8acaf2417 Reviewed-on: https://code.wireshark.org/review/6768 Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
2015-01-02Add '*.nativecodeanalysis.xml' to 'clean' targetsBill Meier1-1/+1
Change-Id: I90dbf0b31fc737150a01533763a7869b34c68cb6 Reviewed-on: https://code.wireshark.org/review/6220 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-19Eliminate use of ctype.h routines.Guy Harris2-4/+6
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-06Adjust some whitespace to match editor modelines.Bill Meier1-8/+8
Change-Id: I9fda7de49255857cc1cf270d6202c85573d91674 Reviewed-on: https://code.wireshark.org/review/4490 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-06Adjust some whitespace to match editor modelines.Bill Meier1-2/+2
Change-Id: Ia22cac3ebd7a454c156f98d967e6fd61f708a2b3 Reviewed-on: https://code.wireshark.org/review/4489 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-16Fix the patch-bzip2 target.Gerald Combs3-3/+3
The main site URI scheme is now https. Update the URL in some other places while we're here. Change-Id: Ib03d4fd1c58dabd3cf5050dc4f79216e0b94d525 Reviewed-on: https://code.wireshark.org/review/4133 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-08-18Fix warning: no previous prototype for ... [-Wmissing-prototypes]Alexis La Goutte1-0/+1
Change-Id: I59e744d905a0a13eea4ff649a984b2ed9f1f51e7 Reviewed-on: https://code.wireshark.org/review/3697 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-08-04Try to detect overflow without causing signedness warnings.Evan Huus1-1/+1
Change-Id: I957ead1f674e2c56e9c741841fea11395769b238 Reviewed-on: https://code.wireshark.org/review/3398 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-08-04Check for multiplicative overflow in the wmem_alloc_array macros.Evan Huus1-2/+5
Bug:10343 Change-Id: Iea511c806b92999b3b497f94886c46a818100a23 Reviewed-on: https://code.wireshark.org/review/3396 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-08-03wmem: get rid of the allocator timing testEvan Huus1-59/+0
Some of the allocators are close enough that a little bit of system load at the time of the test was enough to throw them off, and it was causing unnecessary buildbot failures. Benchmarking on real-world cases at the time of implementation (as well as reliable "average" results on the buildbots) has left me confident that block_fast is, in fact, faster than block, which is faster than simple/strict. Additionally, the allocators are effectively "done" and unlikely to change, so the possibility of uncaught performance regressions is low. Change-Id: I144ea4cd9d6000edc4075ed682ce6a4aeaf5e28a Reviewed-on: https://code.wireshark.org/review/3356 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-07-01Bump (again) the amount of work we do for wmem's timing testEvan Huus1-1/+1
Apparently the new win8 vm has a *very* low-resolution timer, and the allocators are indistinguishable at the previous amount of work. Change-Id: If4e5bb8f85b1f0d39658f54001c88f42ffddfc47 Reviewed-on: https://code.wireshark.org/review/2768 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-28Add Modelines and use tabs and fix typoAlexis La Goutte1-1/+1
Change-Id: Ie3f60f66f0f4a572098d1d7425c53aaf51bdb747 Reviewed-on: https://code.wireshark.org/review/1846 Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-05-23Add jumbo-allocation support to wmem fast blockEvan Huus2-5/+57
As it turns out, we do occasionally need it. Bug:10115 Change-Id: Ifec79e4d2470bbc09f15674534d01418a6571a0d Reviewed-on: https://code.wireshark.org/review/1688 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-21Remove extra parentheses.Gerald Combs1-1/+1
Fix the clang warning epan/wmem/wmem_allocator_simple.c:49:27: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality] if ((allocator->count == allocator->size)) { ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ We might want to add -Wno-parentheses-equality to the compiler flag list but I'm not sure if doing so would hide valid problems. Change-Id: Id59b55af1411f13309fbec77870f869e04a6f49f Reviewed-on: https://code.wireshark.org/review/1717 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-05-17Fix newly optimized strdup_vprintf.Evan Huus2-5/+11
As Jakub pointed out, our +1/-1 logic for null terminators wasn't quite right. Also be sure to re-copy the va_list parameter if we need to re-use it, as otherwise things break oddly. Change-Id: Ibeaa95af602f565791e9378a6cfce434f13025eb Reviewed-on: https://code.wireshark.org/review/1670 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-17Fixes after wmem_strdup_vprintf() optimizationJakub Zawadzki1-7/+7
- g_vsnprintf()[1] buffer size can includes space for terminating NUL, this simplifies code, and fix problems with string truncation - g_vsnprintf() returns number of bytes without terminating NUL, so we need to do + 1 - second g_vsnprintf() call use already consumed 'ap2' va_arg, which makes wmem_strdup_vprintf() doesn't work/ crash for FORMATTED string length > 80 [1] https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-vsnprintf Change-Id: I0ebb7f452e3e89c9b55f8ac889166f02e8a7c982 Reviewed-on: https://code.wireshark.org/review/1667 Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-05-17Use a pre allocated buffer in wmem_strdup_vprintf() reduces the functionAndersBroman1-4/+21
cost by more than half. Change-Id: I6ad2ae407325d2091ffb60919cb3ed74f78f39fa Reviewed-on: https://code.wireshark.org/review/1662 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-13Dumber "simple" wmem allocator.Evan Huus1-39/+41
Instead of maintaining a hash table, just alloc a really big array of pointers. This is theoretically bad since it means frees and reallocs become O(n), but in practice it makes the capture from bug 10098 run about 20% faster under valgrind. This makes sense, since the workload is heavily dominated by allocations, and most frees/reallocs are recently allocated (so they will be found quickly at the beginning of the scan). Bug:10098 Change-Id: I7097ad0653d3fb5f4f723cc84046cbc4450e3494 Reviewed-on: https://code.wireshark.org/review/1602 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-06Increase the work used to time wmem allocatorsEvan Huus1-1/+7
It appears that on some platforms the timer underlying g_test_timer() is relatively low-precision, so the small amount of work that we were previously doing was not enough for the timer to provide a useful value. Bumping the amount of work should provide more meaningful values, and the whole timing step still takes only a few seconds. Change-Id: Idce1386eaa33add845d9a2758b0beb72bbf370d6 Reviewed-on: https://code.wireshark.org/review/1523 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-05Fix dead assignment found by clang in test codeEvan Huus1-1/+1
Change-Id: Ie78769bfd8034f6c2ee7d9e26a209d650cedb98d Reviewed-on: https://code.wireshark.org/review/1507 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-05-05Reduce wmem fast-block fuzz rounds even furtherEvan Huus1-1/+1
Follow-up to g19e650f43adf23b0aa92821bff0cc389643944f6 since the fuzz-bot is still failing. Change-Id: I2d05a861b0edf50ce734b682e6e3e33729bf6771 Reviewed-on: https://code.wireshark.org/review/1503 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-05Several tweaks to fast block allocatorEvan Huus1-45/+24
- manually inline wmem_block_fast_add_to_block_list, it was only two lines and only called twice, so the function boilerplate was outweighing the abstraction - change free_all to release all but one block to the OS immediately, making gc a no-op; the alloc logic doesn't reuse later blocks anyways, so this was effectively a leak Change-Id: I033fbb2f3d87e58c7346cba10f2c710eaaa49e9f Reviewed-on: https://code.wireshark.org/review/1499 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-05Fast block allocator: make wmem_block_fast_hdr_t single linked list.Jakub Zawadzki1-4/+1
Double linked list was required by jumbo allocation. No support for jumbo -> no need for double linked list -> have only 'next' pointer in header. Change-Id: I48a0f468ebba9db3a63548d8e7307b6424c759ed Reviewed-on: https://code.wireshark.org/review/1495 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-04Fuzz fewer iterations of the fast block allocatorEvan Huus1-6/+11
I believe the XP buildbot failures are simply running out of memory, so hopefully reducing the number of iterations should be enough to let it finish reliably. Change-Id: I40af789d528c2623e95f153529205b5e617c6e02 Reviewed-on: https://code.wireshark.org/review/1496 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-05-02wmem: add new simple block allocator, use it in packet-scope.Jakub Zawadzki7-35/+375
For packet-scope allocation, there's no need to support realloc(), free() cause memory will be garbage collected after packet dissection. (and this allocator is much faster than full block allocator). Change-Id: I73fdf708c3077f48f55bdcc71f4fa859e4ac2335 Reviewed-on: https://code.wireshark.org/review/1428 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-02Reintroduce wmem_allocator_force_newEvan Huus1-4/+36
We now have to call wmem_init in order to randomly seed the values for wmem_map. This means we can no longer rely on the lack of override, so we have to force the right allocator type when testing/timing the allocators themselves. Change-Id: I005034465b0a98f19876899b96ef65b3e4b1d759 Reviewed-on: https://code.wireshark.org/review/1468 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-02Optimize wmem_strbuf_grow.Evan Huus1-0/+8
As suggested by Anders, in the case of repeated calls to wmem_strbuf_append_c (and other functions which append very little data) the growth check was a substantial portion of the over-all running time. By short-circuiting the check in the case where growth isn't needed (as opposed to letting it fall-through naturally) we shave ~25% off the cost of such repeated calls in my benchmarks. The function (wmem_strbuf_grow) is inline, so the compiler should be able to optimize each caller individually for the short-circuit. Change-Id: I76419020f4d8fa675906eb77798969b6c61c7732 Reviewed-on: https://code.wireshark.org/review/1467 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-30Fix indent (Use Tab)Alexis La Goutte1-5/+5
Change-Id: I811fb3db41a31d2334eb80f1821beea109bfa0d9 Reviewed-on: https://code.wireshark.org/review/1437 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-29Fix an extraneous parentheses warning.Gerald Combs1-1/+1
"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-27Fix rare case of wmem map being O(n)Michael Mann1-0/+2
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-25Support out-of-source checkapiStig Bjørlykke1-1/+2
Always call $(top_srcdir)/tools/checkAPIs.pl with -sourcedir=$(srcdir) from Makefile.am to allow out-of-source 'make checkapi'. Change-Id: I60d7e0079984a8ededdacf4517a0738486fa7973 Reviewed-on: https://code.wireshark.org/review/1294 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-23Add a cast to satisfy mac buildbot.Evan Huus1-1/+1
Change-Id: I625b025d3f8a57812512497c6104977ae5d10232 Reviewed-on: https://code.wireshark.org/review/1298 Reviewed-by: Evan Huus <eapache@gmail.com>