Commit Graph

358 Commits

Author SHA1 Message Date
Alexis La Goutte 05ce6efb8c Fix warning when generate documentation (doxygen)
wireshark/epan/wmem/wmem_stack.h:39: Warning: group wmem-stack: ignoring title "Stack-bbab" that does not match old title "Queue"

Change-Id: I9376651d89d9df21aeca82ddb952c230d546169a
Reviewed-on: https://code.wireshark.org/review/1130
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-14 20:18:29 +00:00
Evan Huus 5ad84a9ed1 Fix non-standard format specifiers
C90 permits plain %f for doubles. Thanks to Alexis for pointing this out.

Change-Id: I3f927b0a50e5764c2297c7f9d680c6363ba9fd0e
Reviewed-on: https://code.wireshark.org/review/1073
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-04-12 00:25:38 +00:00
Evan Huus b238cd1541 Scrap wmem splay trees for now.
There is confusion about API usage, and problems on my part concerning whether
keys should be compared signed or unsigned, and how to do that efficiently.
Unsigned keys in particular were behaving oddly.

Change-Id: I075693bbd04c15f79f24f9a24006003a914cc572
Reviewed-on: https://code.wireshark.org/review/924
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-02 17:14:16 +00:00
Alexis La Goutte 757aa33220 Continue to remove $Id$ from top of file
(Using sed : sed -i '/^\# \$Id\$/,+1 d') (start with dash)

Change-Id: Ia4b5a6c2302f6a531f6a86c1ec3a2f8205c8c2dd
Reviewed-on: https://code.wireshark.org/review/881
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-31 18:48:06 +00:00
Evan Huus a8f1e349c3 Doc tweaks and macro parameterization
Change-Id: I9898bedf05a785683e79866a149336cbbf402d27
Reviewed-on: https://code.wireshark.org/review/892
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-31 18:44:26 +00:00
AndersBroman 6a3394eefa Inlining wmem_strbuf_grow seems to give better performance.
Change-Id: I80f3d42fb01461af97984b463a6e8b8217eed552
Reviewed-on: https://code.wireshark.org/review/888
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-31 15:20:08 +00:00
Evan Huus 7df883954e Splay tree implementation for wmem
This is a tree implementation intended to replace the current red-black tree in
wmem_tree (which was inherited from emem), assuming there are no regressions.
Splay trees bubble recently accessed keys to the top, and as such have a number
of very nice properties: https://en.wikipedia.org/wiki/Splay_tree

This implementation is a variant known as "independent semi-splaying", which has
better practical performance. It should do about as well as the red-black tree
for random insertions and accesses, but somewhat better for patterned accesses
(such as accessing each key in order, or accessing certain keys very
frequently).

There are a few other changes relative to the red-black tree implementation that
are worth mentioning:
 - Instead of requiring complex keys to be split into guint32 chunks and doing
   this weird trick with sub-trees, I let the keys be arbitrary pointers and
   allowed the user to specify an arbitrary comparison function. If the function
   is NULL then the pointers are compared directly for the simple integer-key
   case.
 - Splay trees do not need to store a red-black colour flag for each node. It is
   also much easier to do without the parent pointer in each node. And due to
   the simpler system for complex keys, I was able to remove the "is_subtree"
   boolean. As such, splay nodes are 12 bytes smaller on 32-bit platforms, and
   16 bytes smaller on a 64-bit platform.

All done in about half the lines of code.

Change-Id: I89fb57e07d2bb7e3197190c7c2597b0c5adcc03b
Reviewed-on: https://code.wireshark.org/review/758
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-29 18:01:55 +00:00
Evan Huus 48fc43baad Implement finalize() method for wmem strbuf.
Change-Id: Ib7a2b0d348b3624f41253e2d0995a4a38a9fe45d
Reviewed-on: https://code.wireshark.org/review/859
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-29 12:11:21 +00:00
AndersBroman 86d65a0758 Introduce wmem_ascii_strdown()
Change-Id: Icdc5a0d5033f3ab709fbf19a33ab26f609d4b1f0
Reviewed-on: https://code.wireshark.org/review/824
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-25 16:10:43 +00:00
Evan Huus 35098d20a2 Fix memory-alignment in the block allocator.
The previous macro gave the correct alignment, but there was one case where it
would add a whole block of unnecessary ALIGN_SIZE bytes. The new one is also
slightly faster to compute.

Benchmark win of about 3%.

Change-Id: I5d8bad0f78dc0e383e14c2c7a951328a06400020
Reviewed-on: https://code.wireshark.org/review/492
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-04 17:09:40 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Evan Huus 01467c294a Remove assertions from block allocator.
It has been extremely well-tested at this point, and is a very hot code path so
the performance gain is measurable (~1-2% on most captures I tried).

Change-Id: I2f5e03d2f348f56e740bf0dfbc83a4fd9cc8c5a9
Reviewed-on: https://code.wireshark.org/review/499
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:18:51 +00:00
Evan Huus 36e68f7b36 From Jim Young via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9613
Don't use "rand" as a variable name, it shadows a global in recent MacOSX
stdlib.h

svn path=/trunk/; revision=54598
2014-01-05 00:47:24 +00:00
Evan Huus 1dfa4e2697 Add wmem_destroy_list, wmem_destroy_queue, wmem_destroy_stack so that those
data-structures can be used with manually managed memory.

svn path=/trunk/; revision=54432
2013-12-24 01:17:41 +00:00
Anders Broman 350a207a22 Try to please the buildbot.
svn path=/trunk/; revision=54281
2013-12-20 06:50:46 +00:00
Anders Broman 5fbfa6c351 Fix [-Wmissing-prototypes]
svn path=/trunk/; revision=54280
2013-12-20 06:30:13 +00:00
Jakub Zawadzki 2c015bb386 Fix some const/ not const warnings.
svn path=/trunk/; revision=54114
2013-12-15 12:35:00 +00:00
Evan Huus d04079eedc Expose wmem_list_remove_frame to make it efficient to do pop operations as
wmem_list_remove_frame(wmem_list_tail())

svn path=/trunk/; revision=53088
2013-11-05 17:28:19 +00:00
Evan Huus 1f3549168d Don't link explicitly with libwmem, it's already in libwireshark and the symbol
doubling leads to all sorts of very subtle badness (including test failures due
to funny internal assertions because the two wmems have mismatching state).

Make wmem_init and wmem_cleanup PUBLIC instead of LOCAL so that they don't get
stripped and don't cause a link failure when trying to build oids_test (now that
it's not linking with libwmem explicitly). There is possibly a better way to fix
this, but I'm not sure what it is.

svn path=/trunk/; revision=52694
2013-10-19 19:40:02 +00:00
Evan Huus 7b3dfaa525 As suggested separately by both Jakub and Anders: only read the
WIRESHARK_DEBUG_WMEM_OVERRIDE environment variable once in wmem_init, not every
time wmem_allocator_new is called. We currently create a new pinfo pool for
every packet we dissect, so this is a small performance win, especially when
getenv is slow (which may happen if a large number of environment variables are
set, such as when fuzz-testing).

svn path=/trunk/; revision=52634
2013-10-15 23:16:35 +00:00
Evan Huus 7d66e3806b Don't do canaries in blocks of guint32, it appears to cause alignment issues
when running tests on Solaris. Revert back to byte-at-a-time, but do fewer bytes
to avoid a performance hit.

svn path=/trunk/; revision=52617
2013-10-15 13:15:38 +00:00
Evan Huus e7a0c26bec Subsume README.binarytrees into wmem doxygen. The README was out of date
anyways, since Michael made key operations non-destructive in r44380.

svn path=/trunk/; revision=52583
2013-10-13 13:13:24 +00:00
Evan Huus dc0b7253e4 Don't assert that the key to a wmem tree operation is short. If XMPP wants to
use a 1500-byte string as a key, so be it. It will be slow, but at least it will
work.

Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9078

svn path=/trunk/; revision=52261
2013-09-28 23:45:18 +00:00
Evan Huus 5f7187c658 Cycle the recycler in realloc() and free() as well, reducing memory usage of the
stress-test by another ~10%.

svn path=/trunk/; revision=51840
2013-09-08 15:18:55 +00:00
Evan Huus 3c1e67c22d Send all alloc and free calls within wmem through wmem_alloc and wmem_free with
a NULL allocator. This gives us a single, central place to handle out-of-memory
errors (by, for example, throwing an exception) for basically all of epan.

The only remaining glib memory that is directly allocated is for the hash tables
used by the simple and strict allocators.

svn path=/trunk/; revision=51627
2013-09-01 13:37:38 +00:00
Evan Huus d939a6dec0 Do our list manipulation entirely after the realloc, so that if the realloc
doesn't return (do to, for example, throwing an exception) the allocator is
left in a consistent state.

svn path=/trunk/; revision=51626
2013-09-01 13:07:22 +00:00
Evan Huus f875bf8de2 In the strict allocator, do canaries in units of guint32 instead of guint8. This
makes canary checking about 20% faster, which should speed up fuzz-testing now
that more and more dissectors use wmem.

svn path=/trunk/; revision=51620
2013-08-31 16:36:37 +00:00
Guy Harris e8f42c6b48 Include config.h first; it defines _FILE_OFFSET_BITS, and if some system
header later causes it to be redefined - as happens on my Solaris 11
virtual machine - we get a redefinition warning, which gets treated as
an error.

svn path=/trunk/; revision=51344
2013-08-14 00:31:14 +00:00
Evan Huus d8f00e22e1 As suggested in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9033
Make epan_free a no-op if the pointer is NULL. This fixes 99% of the cases
causing problems for wmem_leave_file_scope() - remove that XXX comment and add
back the assertion.

Remove the cleanup_dissection call from epan_cleanup, it doesn't make sense
there. init_dissection is only called from epan_new, so cleanup_dissection
should only be called from epan_free.

Add one missing epan_free call to tshark revealed by the above changes.

svn path=/trunk/; revision=51342
2013-08-13 22:41:34 +00:00
Evan Huus 616324c21e Be sure to initialize the jumbo flag when creating a new chunk header by
splitting an existing chunk. Thanks to Jeff for catching this one.

svn path=/trunk/; revision=51325
2013-08-12 23:35:35 +00:00
Evan Huus bf0f0ec4d9 Reorder and group chunk header flags. Reduces the bit-twiddling needed by the
compiler and provides a surprising (if fairly small) performance win.

svn path=/trunk/; revision=51305
2013-08-11 23:49:56 +00:00
Evan Huus dc46cb0f29 Split jumbo_free and jumbo_realloc into their own functions for readability and
consistency (they are called just once and will be inlined by any reasonable
compiler).

Also add some comments, fix some spacing etc. No functional changes.

svn path=/trunk/; revision=51304
2013-08-11 22:32:46 +00:00
Evan Huus 6eef00ac05 Move the null check outside the function call. Simpler, and more efficient for
compilers that decide not to inline.

svn path=/trunk/; revision=51303
2013-08-11 22:20:35 +00:00
Evan Huus 497e53ee06 Little optimization: move two statements inside an if block.
svn path=/trunk/; revision=51302
2013-08-11 19:33:30 +00:00
Evan Huus 36ff6f2c25 Add support for allocating more than will fit in a single block, through the use
of a jumbo flag in the chunk header.

svn path=/trunk/; revision=51299
2013-08-11 17:18:19 +00:00
Evan Huus 959ee8f5c0 Instead of using a glib slist to track the list of blocks, embed a short
doubly-linked list at the head of each block. This was intended as a step
towards supporting allocations bigger than the usual block size, but also shows
up as a 2% performance improvement in the speed test, so win-win.

svn path=/trunk/; revision=51298
2013-08-11 16:06:07 +00:00
Evan Huus 3bac7e845b Small optimization: the master-list and recycler cases are different enough that
doing all the safety checks was unnecessarily slow. Do only the appropriate
checks for each case.

svn path=/trunk/; revision=51296
2013-08-11 14:20:00 +00:00
Alexis La Goutte d26b7fc516 Fix (-W)documentation error found by Clang
../../epan/wmem/wmem_user_cb.h:52:11: error: parameter 'allocator' not found in the function declaration
      [-Werror,-Wdocumentation]
 * @param allocator The allocator that triggered this callback.
          ^~~~~~~~~
../../epan/wmem/wmem_user_cb.h:53:11: error: parameter 'event' not found in the function declaration
      [-Werror,-Wdocumentation]
 * @param event     The event type that triggered this callback.
          ^~~~~
../../epan/wmem/wmem_user_cb.h:54:11: error: parameter 'user_data' not found in the function declaration
      [-Werror,-Wdocumentation]
 * @param user_data Whatever user_data was originally passed to the call to
          ^~~~~~~~~
../../epan/wmem/wmem_user_cb.h:63:11: error: parameter 'recurring' not found in the function declaration
      [-Werror,-Wdocumentation]
 * @param recurring If this is FALSE then the callback is called exactly once.
          ^~~~~~~~~
4 errors generated.

svn path=/trunk/; revision=51259
2013-08-10 21:28:42 +00:00
Evan Huus 1c2cb57a38 Enhance verification to assert that the recycler and master list contain all
free chunks of sufficient size.

svn path=/trunk/; revision=51234
2013-08-09 11:20:02 +00:00
Evan Huus c5319ebc93 One more chunk header alignment fix.
svn path=/trunk/; revision=51218
2013-08-08 12:23:23 +00:00
Evan Huus 0ebe18dcea Make sure our chunk headers are large enough to correctly align the actual data
pointer we return.

svn path=/trunk/; revision=51217
2013-08-08 11:27:39 +00:00
Evan Huus d8684cf32d When splitting a free chunk, if we don't have room for a free header don't even
bother splitting. This greatly simplifies the logic, trims another 4% off the
fast path, and doesn't actually affect the results at all because of the way we
pad for alignment anyways.

svn path=/trunk/; revision=51216
2013-08-08 11:16:10 +00:00
Evan Huus c4e966b880 Combine two ternary ?: into a single if. Shaves about 1.5% off the fast timing
test.

svn path=/trunk/; revision=51112
2013-08-02 01:58:52 +00:00
Evan Huus a7b30a2a2c Small simplification
svn path=/trunk/; revision=51111
2013-08-02 01:51:06 +00:00
Evan Huus c85ec68e58 Remove unnecessary null check.
svn path=/trunk/; revision=51110
2013-08-02 01:36:52 +00:00
Evan Huus 64ed83d793 Rewrite the merge_free routine to keep the merged chunk on the master free list
if the right-hand merge target was there originally. This brings memory usage
down another ~40% when running the heavy test suite.

This also lets us extract the master-list check out of unfree() since it is now
only relevant at a single caller, and turns unfree into the more understandable
remove_from_recycler().

svn path=/trunk/; revision=51104
2013-08-02 00:12:12 +00:00
Evan Huus 8fafa9b758 Add wmem_tree_is_empty(). Also permit lookups on a NULL tree for compatibility
with emem.

svn path=/trunk/; revision=51045
2013-07-31 01:48:47 +00:00
Evan Huus 44d53b4042 More little optimizations.
svn path=/trunk/; revision=51014
2013-07-29 16:55:02 +00:00
Evan Huus 0fb6d96507 Another little optimization.
Removes one branch from the hot path, deduplicates one function call in the cold
path by effectively falling through, and makes it more obvious what the code is
actually trying to do.

svn path=/trunk/; revision=51013
2013-07-29 16:47:30 +00:00
Graham Bloice 2f6ee944d8 Added more build artefacts to the clean target
svn path=/trunk/; revision=50977
2013-07-28 14:40:56 +00:00
Evan Huus a9bccc8dc8 Don't force the allocator choice in the data-structure tests, we want to be able
to override that to simple for valgrinding (we still force the allocator in the
allocator and timing tests, of course).

svn path=/trunk/; revision=50971
2013-07-28 12:55:37 +00:00
Evan Huus b43996c8ab Fix a bug in the gc routine discovered while formally working out parts of the
algorithm.

Also add a test case to excercise it for future.

svn path=/trunk/; revision=50970
2013-07-28 12:46:44 +00:00
Evan Huus b9870c0969 Little optimizations.
Move a few assignments around to avoid one extra subtraction. I suspect having
the two if statements next to each other is friendly to the compiler's optimizer
as well.

Shaves ~1.3% off my timing tests, bringing the new design *very* close to the
old one in raw allocation speed.

svn path=/trunk/; revision=50961
2013-07-28 00:00:37 +00:00
Evan Huus e7dfea82f3 Little things make big differences: somehow while I was experimenting this
unobtrusive if statement got dropped. Without it the allocator exhibits the old
bad behaviour of 3x memory usage and heavy fragmentation.

We want it back, thank you very much.

svn path=/trunk/; revision=50960
2013-07-27 23:35:59 +00:00
Evan Huus 9b9467cb79 Small optimization: conjoin two mutually exclusive ifs with an else.
svn path=/trunk/; revision=50959
2013-07-27 23:01:24 +00:00
Evan Huus 720cce4102 Simplify out an addition that happened a lot by performing it once on the
variable it affected, since that variable wasn't used for any other purpose.

svn path=/trunk/; revision=50958
2013-07-27 22:51:27 +00:00
Evan Huus 3663498a8b Redesign of the wmem block allocator.
What was becoming apparent as more dissectors started using wmem was that the
old block allocator design had issues with memory fragmentation. This keeps the
same underlying memory layout, but completely changes how free blocks are kept.
It runs about 3% slower in my tests (still an order of magnitude faster than
g_malloc) but uses about 1/3 the memory.

I suspect some simple optimizations could reclaim that 3% as well - the design
is fast, but I did not code particularly for speed.

Thoroughly tested with the existing test suite (which caught half a dozen bugs
in my first draft) so it should actually work!

svn path=/trunk/; revision=50955
2013-07-27 22:27:28 +00:00
Evan Huus a076d6332e Use a #define, tweak a comment.
svn path=/trunk/; revision=50954
2013-07-27 21:56:43 +00:00
Evan Huus c693d9c951 whitespace
svn path=/trunk/; revision=50919
2013-07-26 16:42:06 +00:00
Evan Huus 037fc022da Add wmem queue 'implementation' by wrapping wmem_list and wmem_stack.
Also a bit of misc. refactoring of the stack while I was there, and doc tweaks.

svn path=/trunk/; revision=50769
2013-07-21 21:13:30 +00:00
Evan Huus 6635f5ef67 Replace wmem slist (singly-linked) with wmem list (doubly-linked).
The overhead is not large, and it makes append much faster (O(1) vs O(n)).

It also will make a queue easy to add, which I need for a dissector I'm
writing...

svn path=/trunk/; revision=50744
2013-07-20 20:33:38 +00:00
Chris Maynard 1c19a0d61e Fix warnings: format '%blah' expects argument of type 'foo', but argument 'i' has type 'bar' [-Wformat].
svn path=/trunk/; revision=50639
2013-07-15 21:22:34 +00:00
Evan Huus e1268955c7 Add wmem_array_sort() which just hands off to the standard library's qsort().
svn path=/trunk/; revision=50411
2013-07-06 17:47:32 +00:00
Guy Harris 24142c4ee4 In some versions of some OSes, even <string.h> declares index() under
some circumstances.  Use array_index as a variable name instead, to
avoid warnings.

svn path=/trunk/; revision=50404
2013-07-06 08:33:07 +00:00
Evan Huus 777f060f01 Trivial code style: use wmem_new in a few places, and remove extraneous
whitespace.

svn path=/trunk/; revision=50401
2013-07-06 04:08:07 +00:00
Evan Huus c574f7d1ea Simple growable array implementation for wmem.
svn path=/trunk/; revision=50400
2013-07-06 04:02:08 +00:00
Evan Huus 31bd48bce3 *sigh*
From the comment above wmem_tree_insert32_array():
 * If you use ...32_array() calls you MUST make sure that every single node
 * you add to a specific tree always has a key of exactly the same number of
 * keylen words or things will most likely crash. Or at least that every single
 * item that sits behind the same top level node always have exactly the same
 * number of words.

So clearly generating thousands of keys with random lengths while testing is
going to cause problems. Generate a set of random lengths, then use those
lengths consistently (but still generating random keys of those lengths).

Should hopefully fix the intermittent build-bot failures.

(unfortunately this does not manifest nicely, and I cannot see an easy way to
assert it so that we catch other people trying to use different-length key
subtrees)

svn path=/trunk/; revision=50184
2013-06-27 03:44:48 +00:00
Evan Huus ffe6d9c4d6 Misc little cleanups to wmem tree (comments, whitespace, assertions)
svn path=/trunk/; revision=50182
2013-06-27 03:01:53 +00:00
Evan Huus 32f4010527 Remove debugging lines from wmem_test, I think I've figured out the problem.
svn path=/trunk/; revision=50181
2013-06-27 03:00:33 +00:00
Evan Huus a69be407ab Arrays seems to be where the failure is, so remove excess verbiage around other
tests, and add more details to that section.

Now we wait for the buildbots to fail again...

svn path=/trunk/; revision=50156
2013-06-25 22:32:53 +00:00
Chris Maynard ce088c334d makefile.nmake -> Makefile.nmake and minor whitespace (spaces -> tabs) changes.
svn path=/trunk/; revision=50140
2013-06-25 15:32:49 +00:00
Evan Huus 6ebdc45af1 Fix wmem_tree.h ifdef guards, hopefully fixing the check-abi buildbot.
svn path=/trunk/; revision=50132
2013-06-24 22:37:04 +00:00
Evan Huus 29c75dae91 So it comes to this...
Put in a whole bunch of stderr output in the wmem tree tests in the hopes that
the next time one of the buildbots randomly (and irreproducibly) fails on this
step we'll have at least a bit of a hint as to where it happened.

svn path=/trunk/; revision=50131
2013-06-24 21:59:02 +00:00
Evan Huus bfa8d9af75 Make assertions in tree lookup more useful and fix formatting.
Should help debugging https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8833

svn path=/trunk/; revision=50115
2013-06-22 21:00:36 +00:00
Evan Huus 5d53d63cd7 From Michal Labedzki via
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8824

Convert bluetooth emem trees to wmem trees.
Add modelines and fix indentation.
Correct typo in wmem_tree.h that still referred to emem.

svn path=/trunk/; revision=50076
2013-06-20 16:31:53 +00:00
Evan Huus e13d73e038 Rework wmem scoping limits so that users can still get a handle to a pool when
it is out of scope, they just can't *allocate* in the pool. This is necessary
because file-scope trees (migrating from emem) are set up on program
initialization when there is no file in scope - they need to initialize with the
handle, they just won't use it until a file is actually in scope.

svn path=/trunk/; revision=50046
2013-06-19 18:28:13 +00:00
Evan Huus a17358cf3f Add wmem_strbuf_new_label as just a sized new for label lengths.
svn path=/trunk/; revision=50039
2013-06-19 17:34:24 +00:00
Evan Huus f4e5a62325 Clean up wmem_strsplit to remove a bunch of weird switch statements and
unnecessary continue statements. Should fix the coverity issues Joerg pointed
out as well.

svn path=/trunk/; revision=50033
2013-06-19 06:48:08 +00:00
Evan Huus 8ec8f94db7 Resurrect wmem_memdup in its own misc. utilities group. Emem provides it, so we
need to provide an analogue at least for now.

svn path=/trunk/; revision=50018
2013-06-18 21:42:54 +00:00
Evan Huus d487bba75f Add wmem_alloc_array, wmem_strsplit, wmem_strconcat.
svn path=/trunk/; revision=50017
2013-06-18 21:25:37 +00:00
Evan Huus da6d99e2c9 Refactor insert32 to use lookup_or_insert32 with the right flags.
svn path=/trunk/; revision=50013
2013-06-18 19:55:29 +00:00
Evan Huus 4313d778f0 Refactor lookup_or_insert32 to remove a bunch of continue and break statements
as well as a confusing while(TRUE).

svn path=/trunk/; revision=50012
2013-06-18 19:43:18 +00:00
Evan Huus 8610601f60 Simplify node structure. Use a boolean for whether or not it's a subtree, and an
enum for the color (red/black). Don't use bitfields since they don't save us
much (if anything) in terms of space and don't nest the fields in their own
anonymous struct.

svn path=/trunk/; revision=50011
2013-06-18 19:32:40 +00:00
Evan Huus 02752f3161 Factor function for node creation out and use it in several places.
svn path=/trunk/; revision=50010
2013-06-18 19:19:21 +00:00
Evan Huus 881845a555 Scrap wmem_memdup, it's not actually as useful as I thought it would be.
svn path=/trunk/; revision=50009
2013-06-18 19:01:01 +00:00
Evan Huus 115eb9c727 Factor common code for red-black tree array lookups into a helper function and
use it for both direct lookups and less-than-or-equal-to lookups.

svn path=/trunk/; revision=50008
2013-06-18 18:57:28 +00:00
Evan Huus 7fd970ac45 Remove wmem_tree_create_subtree, it does nothing we can't do with
wmem_tree_new.

svn path=/trunk/; revision=50007
2013-06-18 17:48:04 +00:00
Evan Huus d0c1d89cd6 Factor string-packing code into a common function to use in both insert_string
and lookup_string.

svn path=/trunk/; revision=50006
2013-06-18 17:39:15 +00:00
Evan Huus 701fb00afa Add test block for wmem_tree_lookup32_array_le(), fix other tests where certain
random seeds would cause collisions and false failures.

svn path=/trunk/; revision=50004
2013-06-18 06:22:47 +00:00
Evan Huus 54959c293d Wmem tree tests with non-trivial keys.
svn path=/trunk/; revision=50003
2013-06-18 05:41:16 +00:00
Evan Huus 7c99d55773 Re-port a bunch of the red-black tree code from wmem with fewer modifications,
and enable the tests.

Lesson: make it work, *then* refactor it into sanity.

svn path=/trunk/; revision=50002
2013-06-18 05:31:12 +00:00
Evan Huus b5c538ff81 Add tests for red-black tree array keys, if0-ed out until I can make them not
blow up. Not sure if the tests are wrong or if I broke something during the port
from wmem...

svn path=/trunk/; revision=49998
2013-06-18 00:21:32 +00:00
Evan Huus 5c027c2590 Extract some common code for array lookups, and replace some DISSECTOR
assertions with regular glib assertions - there's no guarantee that wmem code
will always be run from within a dissector.

svn path=/trunk/; revision=49993
2013-06-17 22:51:50 +00:00
Evan Huus 858cb85eb4 Fix the test to respect the new behaviour.
svn path=/trunk/; revision=49971
2013-06-17 00:45:44 +00:00
Evan Huus fd22c548f5 Much smarter handling of autoreset trees.
svn path=/trunk/; revision=49970
2013-06-17 00:08:44 +00:00
Evan Huus 55264582be More callback tweaks, to permit unregistering a callback from the same place
it was originally registered.

svn path=/trunk/; revision=49969
2013-06-16 22:37:55 +00:00
Evan Huus ffee3af207 Fix include to use "" not <> for local headers.
svn path=/trunk/; revision=49968
2013-06-16 22:25:27 +00:00
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
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