summaryrefslogtreecommitdiff
path: root/epan/wmem/wmem_core.h
AgeCommit message (Collapse)AuthorFilesLines
2016-05-24Document wmem null guaranteeEvan Huus1-0/+4
Change-Id: Ibbbda815b144441f7db2d1920e1551c45e997370 Reviewed-on: https://code.wireshark.org/review/15549 Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2014-08-04Try to detect overflow without causing signedness warnings.Evan Huus1-1/+1
Change-Id: I957ead1f674e2c56e9c741841fea11395769b238 Reviewed-on: https://code.wireshark.org/review/3398 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-08-04Check for multiplicative overflow in the wmem_alloc_array macros.Evan Huus1-2/+5
Bug:10343 Change-Id: Iea511c806b92999b3b497f94886c46a818100a23 Reviewed-on: https://code.wireshark.org/review/3396 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-05-02wmem: add new simple block allocator, use it in packet-scope.Jakub Zawadzki1-4/+9
For packet-scope allocation, there's no need to support realloc(), free() cause memory will be garbage collected after packet dissection. (and this allocator is much faster than full block allocator). Change-Id: I73fdf708c3077f48f55bdcc71f4fa859e4ac2335 Reviewed-on: https://code.wireshark.org/review/1428 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-10-19Don't link explicitly with libwmem, it's already in libwireshark and the symbolEvan Huus1-2/+2
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-09-01Send all alloc and free calls within wmem through wmem_alloc and wmem_free withEvan Huus1-2/+2
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-06-18Add wmem_alloc_array, wmem_strsplit, wmem_strconcat.Evan Huus1-0/+21
svn path=/trunk/; revision=50017
2013-06-18Scrap wmem_memdup, it's not actually as useful as I thought it would be.Evan Huus1-12/+0
svn path=/trunk/; revision=50009
2013-06-09Add memdup function to wmem.Evan Huus1-0/+12
svn path=/trunk/; revision=49857
2013-05-26First batch of doxygen for wmem. Remove some things from README.wmem now thatEvan Huus1-5/+103
they're in doxygen instead. svn path=/trunk/; revision=49583
2013-05-08Round two of wmem cleanup callbacks. While the emem tree behaviour will requireEvan Huus1-8/+1
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-07Add user callbacks to wmem. This feature is a generic way to transparently mimicEvan Huus1-3/+12
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-04-25Annotate wmem functions for better compiler warnings and optimization.Evan Huus1-3/+8
svn path=/trunk/; revision=49041
2013-03-02Export some wmem functions using the new scheme.Evan Huus1-0/+11
svn path=/trunk/; revision=48019
2013-02-08Expose the new wmem API functions, and use a consistent order ofEvan Huus1-2/+13
alloc/free/realloc across all of wmem. svn path=/trunk/; revision=47548
2013-01-04Add convenience macros wmem_new and wmem_new0Evan Huus1-1/+3
svn path=/trunk/; revision=46941
2012-12-28Add a strict allocator that does canaries and various other things, forEvan Huus1-1/+2
platforms which don't have Valgrind. Valgrind is still the better choice on platforms which support it. svn path=/trunk/; revision=46828
2012-12-19Dispatch all allocator creations through a single function using an enum toEvan Huus1-1/+9
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-11-08Use const in wmem where possible.Evan Huus1-2/+2
svn path=/trunk/; revision=45976
2012-11-03Add wmem scopes for packet and file lifetimes. The file lifetime scope isn'tEvan Huus1-3/+0
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-03Rename wmem_permanent_scope -> wmem_epan_scope to reflect the fact that itEvan Huus1-1/+1
is technically scoped to the library, not the process. It's also shorter :) svn path=/trunk/; revision=45877
2012-10-27Create init and cleanup functions for wmem as a whole.Evan Huus1-0/+9
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-27Make the allocator destructor part of wmem_allocator_t. This avoids twoEvan Huus1-0/+3
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-24Have wmem_core.h define the wmem_allocator_t typedef, with an incompleteGuy Harris1-0/+2
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-24Basic skeleton for wmem.Evan Huus1-0/+63
https://www.wireshark.org/lists/wireshark-dev/201210/msg00178.html svn path=/trunk/; revision=45746