Commit Graph

62 Commits

Author SHA1 Message Date
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