c++-gtk-utils
|
A deleter functor for use as the second (Dealloc) template parameter of the SharedHandle, SharedLockHandle or ScopedHandle template classes, which calls glib's g_slice_free1(). More...
#include <c++-gtk-utils/shared_handle.h>
Public Member Functions | |
void | operator() (T obj) |
A deleter functor for use as the second (Dealloc) template parameter of the SharedHandle, SharedLockHandle or ScopedHandle template classes, which calls glib's g_slice_free1().
This functor enables those classes to manage a memory block allocated using glib memory slices. The managed memory block to be deleted by the GSliceFree functor must have the same size as the size of the object for which the functor is instantiated by pointer, as for example as allocated with the g_slice_new, g_slice_new0 or g_slice_dup macros (in other words, the GSliceFree template parameter must match the argument passed to those macros): see the example below. Use GSliceFreeSize where it is necessary or more convenient to have the size of the block to be freed as the template parameter. Use GSliceDestroy where the memory holds a C++ object constructed in the memory by the global placement new expression.
The type of the template argument for the functor is a pointer to the managed type: it is the same as the first template argument of the relevant SharedHandle, SharedLockHandle or ScopedHandle object. For example:
The availability of this functor is not dependent on the library having been installed with the --with-glib-memory-slices-compat or --with-glib-memory-slices-no-compat configuration option (see Memory allocation for further details of those options).
Since 1.0.3
|
inline |