Commit Graph

111 Commits

Author SHA1 Message Date
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 82a13484b3 Add warning comment to tree autoreset function about allocator
destruction order, and note that it may need thinking about.

svn path=/trunk/; revision=49952
2013-06-16 01:47:43 +00:00
Evan Huus 28dafa414a Fix occasional wmem_test failure, allocator destruction order matters
(should it?)

svn path=/trunk/; revision=49951
2013-06-16 01:44:09 +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
Evan Huus 226b39f1d7 Add memdup function to wmem.
svn path=/trunk/; revision=49857
2013-06-09 13:49:16 +00:00
Evan Huus a9c35aa4b6 First batch of doxygen for wmem. Remove some things from README.wmem now that
they're in doxygen instead.

svn path=/trunk/; revision=49583
2013-05-26 02:40:40 +00:00
Evan Huus 5426ba4e02 Minor refactor: make the framework responsible for allocating and freeing the
actual wmem_allocator_t structure. This simplifies the internal API and
deduplicates a few alloc/free calls in the individual allocator implementations.

I'd originally made the allocators responsible for this on purpose with the
idea that they'd be able to optimize something clever based on the type of
allocator, but that's clearly more work and complexity than it's worth given
the small number of allocators we create/destroy.

svn path=/trunk/; revision=49512
2013-05-22 15:42:12 +00:00
Gerald Combs c0702583d3 Make the minimum supported GLib version 2.16.
svn path=/trunk/; revision=49444
2013-05-20 17:27:05 +00:00
Evan Huus f2bdbd2b32 Use a readable name for the wmem callback test. Warn that reallocing memory
for which a callback is registered is also a fairly stupid thing to do.

svn path=/trunk/; revision=49354
2013-05-16 23:38:31 +00:00
Evan Huus d860a01aaf Round two of wmem cleanup callbacks. While the emem tree behaviour will require
recurring callbacks, I suspect most other potential uses will be once-only, so
make that possible, and improve the documentation on the remaining issues.

Also separate out the code into its own files and the testing into its own
test case.

svn path=/trunk/; revision=49209
2013-05-08 01:14:01 +00:00
Evan Huus 2e92c6dfde Add user callbacks to wmem. This feature is a generic way to transparently mimic
the behaviour emem has for seasonal trees, which is that the master tree
structure is not actually seasonal - it is permanent. When the seasonal memory
pool is cleared, the root node pointer in all of these permanent trees is set
to NULL, and the pool takes care of actually freeing the nodes.

Wmem can now mimic this by allocating the tree header struct in epan_scope(),
allocating any node structs in file_scope(), and registering a callback on
file_scope() that NULLs the pointer in the epan_scope() header. Yes, this is
confusing, but it seemed simpler than adding manual callback registrations to
every single dissector that currently uses seasonal trees.

The callbacks may also be useful for other things that need cleanup (I'm
thinking resource handles stored in wmem memory that need to be fclosed or
what-have-you before they the handle is lost).

As indicated by the number of caveats in README.wmem, the implementation
probably needs a bit of work to make it safer/saner/more-useful. Thoughts
(or patches!) in this direction are more than welcome.

svn path=/trunk/; revision=49205
2013-05-07 19:23:10 +00:00
Evan Huus 60fe9f1b9e Stub out the wmem test suite for older Glibs. This should restore
compatibility with GLIB 2.14.

svn path=/trunk/; revision=49161
2013-05-04 12:42:28 +00:00
Evan Huus e8c813b2ea In part from Raúl Pérez Clavero via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8275
Implement wmem_slist_append().

svn path=/trunk/; revision=49094
2013-04-30 01:23:10 +00:00
Evan Huus 5deac1e6e1 Wmem string-buffer improvements:
- better tests
- fix a bug caught by the better tests
- implement append_c and append_unichar, with tests

Wmem string-buffers now have feature parity with their emem equivalents, so
remove them from the TODO list.

svn path=/trunk/; revision=49060
2013-04-26 21:30:24 +00:00
Evan Huus 7d2c6f3000 Annotate wmem functions for better compiler warnings and optimization.
svn path=/trunk/; revision=49041
2013-04-25 22:54:36 +00:00
Evan Huus 2616e09140 Add truncate function to wmem strbuf.
svn path=/trunk/; revision=49010
2013-04-24 00:11:57 +00:00
Evan Huus 43e07d6d0d Add tests for wmem stack, and misc. tweaks to other tests.
The wmem test suite now covers all of the existing allocators, data
structures and utility functions in at least basic cases.

svn path=/trunk/; revision=48980
2013-04-22 21:23:16 +00:00
Gerald Combs 4f9a9cd3d3 Convert another instance of g_assert_cmpuint to g_assert.
svn path=/trunk/; revision=48967
2013-04-22 17:34:50 +00:00
Evan Huus 4983d99475 Improve wmem strbuf tests, add tests for string util. functions
svn path=/trunk/; revision=48964
2013-04-22 15:40:48 +00:00
Evan Huus 6ea50c8d2e Don't use g_assert_cmpuint, its definition breaks the Windows
buildbot for some reason; g_assert works just as well except
for providing less useful output on failures.

svn path=/trunk/; revision=48959
2013-04-22 01:29:13 +00:00
Evan Huus 2b9db8a7d4 Add wmem string-buffer tests and fix associated bugs.
svn path=/trunk/; revision=48957
2013-04-21 23:19:37 +00:00
Evan Huus 29b61239bc Add wmem tests for the singly-linked list implementation.
svn path=/trunk/; revision=48807
2013-04-10 14:11:13 +00:00
Evan Huus ade9361071 Loop the timing test 128 times so that statistics work more in our favour.
Print the times to stdout so that in a failure case we can see how badly it
was off.

svn path=/trunk/; revision=48590
2013-03-27 17:30:12 +00:00
Evan Huus 0d2e02954f Add a timing test to check that the block allocator is actually faster than the
simple one. At the moment it seems to be between 2x and 2.5x faster in the
common case (a simple sequence of allocations followed by free_all).

svn path=/trunk/; revision=48588
2013-03-27 16:37:12 +00:00
Evan Huus 0a8b96a41b Generalize the allocator test function and use it to test the simple and
the strict allocators as well.

svn path=/trunk/; revision=48586
2013-03-27 12:43:29 +00:00
Evan Huus 7959275717 Copy over a missing flag in the block allocator to fix the build-bot failure
at http://buildbot.wireshark.org/trunk/builders/Ubuntu-12.04-x64/builds/4250

Adding --verbose to get the random seed has payed off already!

svn path=/trunk/; revision=48584
2013-03-27 12:01:36 +00:00
Evan Huus 64af18ddda Fix -Wshadow that happens with some old versions of gcc (not mine, for some
reason).

Don't use g_assert_cmpuint, since it apparently causes warnings on windows that
I don't know how to get rid of safely without breaking the conditions being
checked.

svn path=/trunk/; revision=48575
2013-03-27 02:28:45 +00:00
Evan Huus 4252a18c90 Greatly improve wmem tests, including random fuzz-style testing. Improve
assertions in the block allocator, and fix one rare potential underflow caught
by the improved tests.

The tests now take ~200MB and 5-10 seconds to run. Hopefully this is small
enough for the build-bots to handle, if not then we can reduce the max
allocation size or max iterations to suit.

svn path=/trunk/; revision=48574
2013-03-27 00:27:45 +00:00
Guy Harris 986d423b5b Replace implicit conversions with explicit casts.
svn path=/trunk/; revision=48533
2013-03-24 18:17:21 +00:00
Evan Huus d30dbcbf9e Fix a few small bugs in the block allocator and add some more assertions to it
that run during normal usage. Simplify, expand and enable the test coverage,
since what's there now passes.

svn path=/trunk/; revision=48522
2013-03-24 12:53:22 +00:00
Evan Huus 8ccea72f10 Initial simple block allocator tests, not being run by default because they're
failing. I suspect it has to do with my lack of understanding of glib's unit
test framework, not the code being tested.

svn path=/trunk/; revision=48519
2013-03-24 00:45:32 +00:00
Evan Huus 4ba4e1df70 Add wmem unit test binary (still empty) to nmake build and to
the unit test part of the test suite. Once I know it's building and
running properly on the buildbots then I'll actually start writing tests.

svn path=/trunk/; revision=48517
2013-03-23 23:51:07 +00:00
Bill Meier 0df5a9390d From beroset:
remove C++ incompatibilities
 https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 attachment #10397

svn path=/trunk/; revision=48438
2013-03-20 01:18:10 +00:00
Evan Huus 4ef09071b5 Add empty placeholder wmem test suite. Hopefully my automake skills were
up for the challenge.

svn path=/trunk/; revision=48436
2013-03-20 00:28:36 +00:00
Evan Huus 8a874b238e Trivial tweaks to clean up cppcheck warnings.
svn path=/trunk/; revision=48435
2013-03-20 00:10:07 +00:00
Evan Huus b7b30a7cdf More block allocator fixes and cleanup. Most of the issues seem to have been
from one case I consistently forgot when typing it up originally, even though
it's clearly listed several places in my design notes.

Also include an #if0-ed out block of code to redirect emem to wmem for easy
testing (since there are very few common dissectors that use wmem right now).

svn path=/trunk/; revision=48434
2013-03-20 00:04:01 +00:00
Evan Huus 9be306d162 Add more and stricter wmem block allocator debug functions.
Re-enable the block allocator by default in trunk since it is much better
tested now - I've spent some time with a hack redirecting all emem allocations
to wmem, so it's seen a lot of traffic. I will still likely turn it off for
1.10 whenever that branches, just to be safe.

svn path=/trunk/; revision=48416
2013-03-19 15:32:42 +00:00
Jaap Keuter 827eb58b04 From David Arnold:
Replace use of INCLUDES with AM_CPPFLAGS in all Makefiles to placate recent autotools.

svn path=/trunk/; revision=48261
2013-03-12 06:53:39 +00:00
Evan Huus e9e54d662f Minor improvements to block allocator debugging.
svn path=/trunk/; revision=48252
2013-03-11 19:24:51 +00:00
Evan Huus 7f738de7b4 Glib docs recommend using the slice API if you know you won't need to realloc.
svn path=/trunk/; revision=48228
2013-03-10 15:04:04 +00:00
Evan Huus e7de549c8c Add the appropriate new WS_DLL_* declarations to the wmem API.
svn path=/trunk/; revision=48220
2013-03-09 20:25:44 +00:00
Evan Huus aafe8b18e9 Remove the wmem slab. It was an optimization mimicking the emem slab
(removed in r48218) which did nothing particularly useful. Also lets us remove
another debugging environment variable.

svn path=/trunk/; revision=48219
2013-03-09 20:16:33 +00:00
Evan Huus 3e919d2b03 Add a debug function (ifdef'ed out by default) and fix another two bugs found by
reading it's output.

svn path=/trunk/; revision=48198
2013-03-08 18:50:34 +00:00
Evan Huus 680d806afc Add another pair of assertions.
svn path=/trunk/; revision=48197
2013-03-08 18:27:29 +00:00
Evan Huus 66688f928f Use only simple allocators until I can work out the kinks with the block
allocator.

svn path=/trunk/; revision=48194
2013-03-08 17:52:13 +00:00
Evan Huus 1a78a717ed Should fix assertion failure seen by Anders on -dev.
https://www.wireshark.org/lists/wireshark-dev/201303/msg00081.html

svn path=/trunk/; revision=48193
2013-03-08 17:51:45 +00:00
Evan Huus 5c05c9e0e1 Export some wmem functions using the new scheme.
svn path=/trunk/; revision=48019
2013-03-02 21:29:05 +00:00
Balint Reczey 1ebdb2e521 Export libwireshark symbols using WS_DLL_PUBLIC define
Also remove old WS_VAR_IMPORT define and related Makefile magic
everywhere in the project.

svn path=/trunk/; revision=47992
2013-03-01 23:53:11 +00:00
Bill Meier 96a24cc79f Fix spelling/typos found using a list of commonly misspelled words.
The misspellings were mostly in comments but some were
in text strings visible to the user.


svn path=/trunk/; revision=47899
2013-02-26 04:42:26 +00:00