summaryrefslogtreecommitdiff
path: root/epan/wmem/wmem_allocator_simple.c
AgeCommit message (Collapse)AuthorFilesLines
2016-05-13Have wmem conform to checkAPIs.plMichael Mann1-3/+3
Yes, the rename of structure members is a bit hacky. Yes, catering to Windows since "GLib's v*printf routines are surprisingly slow on Windows". But it does pass checkAPIs.pl Change-Id: I5b1552472c83aa2e159f17b5b7eb70b37d03eff9 Reviewed-on: https://code.wireshark.org/review/15404 Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-05-21Remove extra parentheses.Gerald Combs1-1/+1
Fix the clang warning epan/wmem/wmem_allocator_simple.c:49:27: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality] if ((allocator->count == allocator->size)) { ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ We might want to add -Wno-parentheses-equality to the compiler flag list but I'm not sure if doing so would hide valid problems. Change-Id: Id59b55af1411f13309fbec77870f869e04a6f49f Reviewed-on: https://code.wireshark.org/review/1717 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-05-13Dumber "simple" wmem allocator.Evan Huus1-39/+41
Instead of maintaining a hash table, just alloc a really big array of pointers. This is theoretically bad since it means frees and reallocs become O(n), but in practice it makes the capture from bug 10098 run about 20% faster under valgrind. This makes sense, since the workload is heavily dominated by allocations, and most frees/reallocs are recently allocated (so they will be found quickly at the beginning of the scan). Bug:10098 Change-Id: I7097ad0653d3fb5f4f723cc84046cbc4450e3494 Reviewed-on: https://code.wireshark.org/review/1602 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(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>
2013-12-20Fix [-Wmissing-prototypes]Anders Broman1-0/+1
svn path=/trunk/; revision=54280
2013-09-01Send all alloc and free calls within wmem through wmem_alloc and wmem_free withEvan Huus1-15/+20
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-08-14Include config.h first; it defines _FILE_OFFSET_BITS, and if some systemGuy Harris1-2/+2
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-05-22Minor refactor: make the framework responsible for allocating and freeing theEvan Huus1-15/+10
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-03-20Trivial tweaks to clean up cppcheck warnings.Evan Huus1-1/+2
svn path=/trunk/; revision=48435
2013-03-10Glib docs recommend using the slice API if you know you won't need to realloc.Evan Huus1-4/+4
svn path=/trunk/; revision=48228
2013-02-22Validate that the pointer passed to wmem_free is valid when using theEvan Huus1-1/+3
simple allocator. Thanks to Bill Meier for suggesting this. svn path=/trunk/; revision=47815
2013-02-08Expose the new wmem API functions, and use a consistent order ofEvan Huus1-12/+12
alloc/free/realloc across all of wmem. svn path=/trunk/; revision=47548
2013-01-23Handle NULL-pointers and 0-lengths in a much simpler allocator-agnostic way,Evan Huus1-26/+10
and document the fact that allocator authors don't have to care. svn path=/trunk/; revision=47220
2013-01-22More fixes for handling of NULL-pointers and 0-lengths in calls toEvan Huus1-9/+18
malloc/realloc/free. svn path=/trunk/; revision=47215
2013-01-20NULL is also a valid return for g_malloc if the requested size is 0.Evan Huus1-2/+6
svn path=/trunk/; revision=47172
2013-01-20Don't add the new block to the hash table if it is NULL, which is aEvan Huus1-1/+5
valid non-error return from realloc if the new requested size is 0. svn path=/trunk/; revision=47171
2013-01-19Rewrite wmem_allocator_simple to track allocations using a GHashTable instead ofEvan Huus1-27/+71
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-19Add three more slots to the wmem allocater definition (not yet implementedEvan Huus1-1/+5
by any particular allocator) and better document the entire structure. svn path=/trunk/; revision=47163
2012-12-18Rename allocator_glib to allocator_simple, since the block allocator alsoEvan Huus1-0/+109
uses glib and 'simple' describes the intention far better. svn path=/trunk/; revision=46603