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
Evan Huus
48e188b560
Remove blocks from the free list when gc'ing them in wmem's block allocator.
...
Thanks to Jakub Zawadzki for catching this one.
svn path=/trunk/; revision=47843
2013-02-23 22:26:18 +00:00
Evan Huus
9b45e7ad74
Fix an *extraordinarily* embarassing copy-paste error. Much thanks to Bill
...
Meier for finding it before it made it into a stable release!
svn path=/trunk/; revision=47816
2013-02-22 16:41:41 +00:00
Evan Huus
3b5017cc0e
Validate that the pointer passed to wmem_free is valid when using the
...
simple allocator. Thanks to Bill Meier for suggesting this.
svn path=/trunk/; revision=47815
2013-02-22 16:38:22 +00:00
Evan Huus
cb679f279b
If the requested wmem allocator is NULL, take that to mean manually-managed
...
memory. This permits using manually-scoped versions of certain wmem structures.
svn path=/trunk/; revision=47657
2013-02-14 16:23:22 +00:00
Evan Huus
5071e8b627
Add an option for bypassing the wmem slab similar to the one for
...
bypassing the emem slab, to aid in debugging with valgrind.
svn path=/trunk/; revision=47656
2013-02-14 16:07:25 +00:00
Evan Huus
8c8533e0dd
Use the new realloc API when growing a string-buffer.
...
svn path=/trunk/; revision=47571
2013-02-08 17:09:18 +00:00
Evan Huus
e1bfc1c61c
Fix issue where using realloc() to shrink a chunk could result in
...
multiple adjacent free chunks. When splitting a used chunk, the resulting
extra unused chunk may need to be merged to its right.
svn path=/trunk/; revision=47552
2013-02-08 02:40:05 +00:00
Evan Huus
ebc2067e30
Add explicit casts to pacify MSVC buildbot.
...
svn path=/trunk/; revision=47551
2013-02-08 02:15:03 +00:00
Evan Huus
9fcb518818
Make use of the new garbage-collection routines when closing a file.
...
svn path=/trunk/; revision=47550
2013-02-08 01:58:04 +00:00
Evan Huus
b636b88646
Expose the new wmem API functions, and use a consistent order of
...
alloc/free/realloc across all of wmem.
svn path=/trunk/; revision=47548
2013-02-08 01:47:48 +00:00
Evan Huus
eea6cb6315
Rewrite the block allocator to support the new wmem API (realloc, free, gc).
...
Some interesting algorithmic stuff going on in here for those who are
interested.
This completes the allocator rewrites for the API additions, so those can be
exposed now.
svn path=/trunk/; revision=47547
2013-02-08 01:38:03 +00:00
Evan Huus
0cb2a257de
Convert the strict allocator to use a hash table similarly to the simple
...
allocator, allowing it to implement realloc and free.
svn path=/trunk/; revision=47222
2013-01-23 02:31:04 +00:00
Evan Huus
681a3ad5a2
Handle NULL-pointers and 0-lengths in a much simpler allocator-agnostic way,
...
and document the fact that allocator authors don't have to care.
svn path=/trunk/; revision=47220
2013-01-23 01:11:36 +00:00
Evan Huus
c25c5915c5
Add wrapper functions for realloc, free and gc, but don't expose them in the
...
header yet as not all allocators implement them.
svn path=/trunk/; revision=47219
2013-01-23 00:59:38 +00:00
Evan Huus
7ad70545cc
More fixes for handling of NULL-pointers and 0-lengths in calls to
...
malloc/realloc/free.
svn path=/trunk/; revision=47215
2013-01-22 18:46:35 +00:00
Evan Huus
f3ba854bec
NULL is also a valid return for g_malloc if the requested size is 0.
...
svn path=/trunk/; revision=47172
2013-01-20 02:47:58 +00:00
Evan Huus
8df0020ac6
Don't add the new block to the hash table if it is NULL, which is a
...
valid non-error return from realloc if the new requested size is 0.
svn path=/trunk/; revision=47171
2013-01-20 02:44:32 +00:00
Evan Huus
669b98bb5f
Rewrite wmem_allocator_simple to track allocations using a GHashTable instead of
...
a GSList. This permits it to implement the new realloc and free functions. Also
fill in an empty gc function, since there isn't much it can do as far as
garbage-collection goes.
svn path=/trunk/; revision=47169
2013-01-19 19:56:20 +00:00
Evan Huus
21453d5db6
Add three more slots to the wmem allocater definition (not yet implemented
...
by any particular allocator) and better document the entire structure.
svn path=/trunk/; revision=47163
2013-01-19 16:15:32 +00:00
Evan Huus
e963cec25c
Add missing header #include as the slab is part of the API even if nobody
...
outside wmem itself uses it yet.
svn path=/trunk/; revision=47094
2013-01-15 16:27:17 +00:00
Evan Huus
b0a0372cff
Use the block allocator for wmem's file-scope by default.
...
svn path=/trunk/; revision=47093
2013-01-15 16:25:24 +00:00
Evan Huus
bab105d094
Add convenience macros wmem_new and wmem_new0
...
svn path=/trunk/; revision=46941
2013-01-04 22:11:13 +00:00
Evan Huus
8331c0e495
Add a cast to pacify MSVC.
...
svn path=/trunk/; revision=46850
2012-12-29 21:34:57 +00:00
Evan Huus
563d64862a
Implement wmem_strbuf_append_printf.
...
svn path=/trunk/; revision=46846
2012-12-29 20:37:53 +00:00
Evan Huus
0c66691b92
Add a strict allocator that does canaries and various other things, for
...
platforms which don't have Valgrind.
Valgrind is still the better choice on platforms which support it.
svn path=/trunk/; revision=46828
2012-12-28 17:04:23 +00:00
Evan Huus
97ec82d02e
Make the alignment amount for the wmem block allocator into a #define
...
and use what appears to be the sanest calculation for it that I can find.
svn path=/trunk/; revision=46820
2012-12-27 23:11:47 +00:00
Evan Huus
bb3b34d7bf
Pre-declare just the enum, and not the typedef to avoid redefinition warnings.
...
svn path=/trunk/; revision=46818
2012-12-27 22:59:29 +00:00
Evan Huus
442b61d0a4
Change the format of the environment variable slightly to allow overriding
...
allocator choice to use any specific allocator, not just simple.
svn path=/trunk/; revision=46816
2012-12-27 22:51:33 +00:00
Evan Huus
dc98756ca4
Store the type of each wmem allocator.
...
svn path=/trunk/; revision=46814
2012-12-27 22:31:42 +00:00
Guy Harris
8ed7a73e22
Fix a bunch of warnings.
...
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().
Change some data types to avoid those implicit conversion warnings.
When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.
Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers. Cast
away those warnings in some cases where an API we don't control forces
us to do so.
Enable a bunch of additional warnings by default. Note why at least
some of the other warnings aren't enabled.
randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.
If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.
svn path=/trunk/; revision=46748
2012-12-26 05:57:06 +00:00
Guy Harris
292b386089
See if *this* squelches the MSVC errors.
...
svn path=/trunk/; revision=46611
2012-12-19 04:30:02 +00:00
Evan Huus
3739c083bf
Implement a basic singly-linked for wmem.
...
Re-implement the stack as a wrapper for that.
svn path=/trunk/; revision=46607
2012-12-19 01:37:28 +00:00
Evan Huus
77d69b36b2
Try to fix windows builds - MSVC doesn't like g_assert_not_reached() ?
...
svn path=/trunk/; revision=46606
2012-12-19 01:08:21 +00:00
Evan Huus
03af5455c7
Make the wmem string-buffer marginally useful but providing some accessors so
...
it's not a write-only data structure.
svn path=/trunk/; revision=46605
2012-12-19 00:51:48 +00:00
Evan Huus
5cf858ec52
Dispatch all allocator creations through a single function using an enum to
...
determine the desired type. This has two advantages over the old way:
- just one environment variable for valgrind to override in order to guarantee
that ALL allocators use memory it can track, and just one place to check that
variable
- allocator owners no longer have to include headers specific to their
allocator, allowing them to change allocators without adjusting all their
#includes
svn path=/trunk/; revision=46604
2012-12-19 00:43:36 +00:00
Evan Huus
561525cbb5
Rename allocator_glib to allocator_simple, since the block allocator also
...
uses glib and 'simple' describes the intention far better.
svn path=/trunk/; revision=46603
2012-12-18 23:36:45 +00:00
Evan Huus
8b69e3ee22
Use 'new' instead of 'create' a consistent manner.
...
svn path=/trunk/; revision=46601
2012-12-18 23:25:11 +00:00
Evan Huus
92cfec56b8
Basic wmem string-buffer. Not yet feature-equivalent to the emem version.
...
svn path=/trunk/; revision=46540
2012-12-15 00:46:36 +00:00
Evan Huus
ea47ca37b1
Put in a cast to silence a stupid MSVC warning.
...
svn path=/trunk/; revision=46473
2012-12-08 22:00:17 +00:00
Evan Huus
af700fa79a
Make sure the wmem block allocator returns aligned memory.
...
svn path=/trunk/; revision=46468
2012-12-08 21:08:29 +00:00
Evan Huus
f4a786638b
Add strdup_printf and strdup_vprintf to the wmem string utilities.
...
svn path=/trunk/; revision=46177
2012-11-25 14:16:50 +00:00
Evan Huus
0d1f86c33e
Allocate wmem memory in blocks of 8MB, not 10, because powers of two are nice.
...
svn path=/trunk/; revision=46175
2012-11-25 13:58:06 +00:00
Evan Huus
706211b642
Make the wmem scopes friendly to the valgrind script like emem is.
...
svn path=/trunk/; revision=46171
2012-11-24 19:02:05 +00:00
Evan Huus
ea7e8174c0
Reorder the wmem scopes to be ordered by lifetime, which makes more sense than
...
the old ordering.
svn path=/trunk/; revision=46168
2012-11-24 18:47:50 +00:00
Evan Huus
a4b164680b
Add a simple block allocator to wmem (no canaries or anything yet) and use it
...
for packet-scope memory.
svn path=/trunk/; revision=46166
2012-11-24 18:42:56 +00:00
Evan Huus
9f03dfb42d
Enter and leave wmem's file scope appropriately.
...
svn path=/trunk/; revision=45977
2012-11-09 00:08:27 +00:00
Evan Huus
82501433e3
Use const in wmem where possible.
...
svn path=/trunk/; revision=45976
2012-11-08 23:18:26 +00:00
Evan Huus
5d6b306391
Wmem stack implementation using the wmem slab implementation to allocate frames.
...
svn path=/trunk/; revision=45881
2012-11-03 17:34:28 +00:00
Evan Huus
2737b7b7d3
Add wmem scopes for packet and file lifetimes. The file lifetime scope isn't
...
yet initialized because I can't figure out where the enter() and leave() calls
should go - the obvious place in packet.c causes a lot of assertion errors.
svn path=/trunk/; revision=45879
2012-11-03 15:49:15 +00:00
Evan Huus
6ef55f30d8
Rename wmem_permanent_scope -> wmem_epan_scope to reflect the fact that it
...
is technically scoped to the library, not the process. It's also shorter :)
svn path=/trunk/; revision=45877
2012-11-03 15:08:00 +00:00
Evan Huus
a02e765e00
Experimental slab allocator logic for wmem.
...
Thanks to Sébastien Tandel for the idea.
svn path=/trunk/; revision=45809
2012-10-27 15:35:32 +00:00
Evan Huus
b464dcd888
Create init and cleanup functions for wmem as a whole.
...
Call them from epan_init() and epan_cleanup().
Expose a permanent wmem scope for allocations that should only be freed when
epan is done (which is *not* necessarily when the program finishes).
svn path=/trunk/; revision=45805
2012-10-27 02:42:05 +00:00
Evan Huus
2ea364607a
Make the allocator destructor part of wmem_allocator_t. This avoids two
...
potential bugs:
- calling the wrong destroy function on an allocator
- a pool allocator forgetting to call free_all on itself in the destructor
Also, fix potential typedef redefinition warning in wmem_allocator_glib.h
svn path=/trunk/; revision=45804
2012-10-27 02:29:46 +00:00
Evan Huus
e6639e035e
Don't use g_slist_free_full() it needs a more recent GLIB than we officially
...
require.
svn path=/trunk/; revision=45781
2012-10-24 22:14:32 +00:00
Guy Harris
1340194a62
wmem_allocator_t is defined in wmem_core.h; redefining it elsewhere will
...
cause errors.
svn path=/trunk/; revision=45771
2012-10-24 18:38:55 +00:00
Guy Harris
1bc158e695
Include wmem_core.h to define the wmem_allocator_t typedef.
...
svn path=/trunk/; revision=45753
2012-10-24 05:52:55 +00:00
Guy Harris
7079f979c3
We're no longer defining the structure in a typedef definition, so we
...
don't want the typedef name after the structure definition.
svn path=/trunk/; revision=45752
2012-10-24 05:37:15 +00:00
Guy Harris
3e1dae3c8d
Make it a little more like the Makefile.am for the ftypes subdirectory.
...
Get rid of reference to non-existent Custom.common file.
svn path=/trunk/; revision=45751
2012-10-24 05:30:14 +00:00
Guy Harris
c1e2438551
Have wmem_core.h define the wmem_allocator_t typedef, with an incomplete
...
structure definition of struct _wmem_allocator_t; have wmem_allocator.h
give the complete structure definition. That avoids complaints about
the typedef being redefined.
svn path=/trunk/; revision=45750
2012-10-24 05:21:43 +00:00
Evan Huus
4e3ddfc4c1
Fix autotools build - missed a few spots that needed updating for wmem.
...
svn path=/trunk/; revision=45748
2012-10-24 03:44:34 +00:00
Evan Huus
84cc3daa3b
Basic skeleton for wmem.
...
https://www.wireshark.org/lists/wireshark-dev/201210/msg00178.html
svn path=/trunk/; revision=45746
2012-10-24 02:04:40 +00:00