From 5426ba4e027326d7b5bea08fd1bb8cfab0847c76 Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Wed, 22 May 2013 15:42:12 +0000 Subject: 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 --- doc/README.wmem | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'doc') diff --git a/doc/README.wmem b/doc/README.wmem index 31ebf1bf11..9bdf4e4f7b 100644 --- a/doc/README.wmem +++ b/doc/README.wmem @@ -284,23 +284,24 @@ and realloc) are non-0. - free_all() - gc() - - destroy() - -The free_all() function takes the private_data pointer and should free all the -memory currently allocated in the pool. Note that this is not necessarilly -exactly the same as calling free() on all the allocated blocks - free_all() is -allowed to do additional cleanup or to make use of optimizations not available -when freeing one block at a time. - -The gc() function takes the private_data pointer and should do whatever it can -to reduce excess memory usage in the dissector by returning unused blocks to -the OS, optimizing internal data structures, etc. - -The destroy() function does NOT take the private_data pointer - it instead takes -a pointer to the allocator structure as a whole, since that structure may also -need freeing. This function can assume that free_all() has been called -immediately before it (though it can make no assumptions about whether or not -gc() has ever been called). + - cleanup() + +All of these functions take only one parameter, which is the allocator's +private_data pointer. + +The free_all() function should free all the memory currently allocated in the +pool. Note that this is not necessarily exactly the same as calling free() +on all the allocated blocks - free_all() is allowed to do additional cleanup +or to make use of optimizations not available when freeing one block at a time. + +The gc() function should do whatever it can to reduce excess memory usage in +the dissector by returning unused blocks to the OS, optimizing internal data +structures, etc. + +The cleanup() function should do any final cleanup and free any and all memory. +It is basically the equivalent of a destructor function. For simplicity, wmem +is guaranteed to call free_all() immediately before this function. There is no +such guarantee that gc() has (ever) been called. 4.2 Pool-Agnostic API -- cgit v1.2.3