Next: Consolidated Disposal Manager Construct, Previous: Memory Allocator Construct, Up: Generic Constructs [Index]
See Temporaries.
Most temporaries reserve memory, memory that needs to be freed once temporaries come out of existence. For memory management purposes, the temporaries allocator construct inherits the memory allocator construct.
See Memory Allocator Construct.
Some temporaries require more complex collection processes than just simple memory deallocation. For such temporaries management purpose, the temporaries allocator construct describes two additional methods, one registering a temporary collection procedure and one unregistering such a procedure.
the method is expected to register one procedure collecting a temporary. When called, the procedure will be supplied a pointer hinting the temporary being collected as its sole argument. The pointer needs to be recorded by the temporaries allocator construct together with the collecting procedure.
Additionally, the (temporary collection procedure registering) method allocates a memory segment of some specified size. The allocated segment needs not be freed explicitely, as it is automatically freed when executing the temporary collection procedure.
Since the temporary is allowed be stored in the allocated segment, and thus the temporary hinting pointer is allowed to not be available when the (temporary collection procedure registering) method is called, the method makes available the address from which the temporary hinting pointer is read.
It is declared as:
int (*pick)(void *, void ***, int (*)(void *), unsigned, void **);
It is passed the temporaries allocator context (the one context pointer
inherited from the memory allocator construct), the address where to store the
address from where the temporary hinting pointer is read, the procedure to
register, the size (expressed in bytes) of the memory segment to allocate and
the address where to store the start address of the allocated memory segment as
arguments, in this order. NULL
may be provided for the last argument,
case in which no allocated memory segment address will be stored.
The registered procedure is expected to return 0
for success, non zero
for failure.
The method is expected to return 0
for success, non zero for failure.
the method is expected to unregister a previously registed temporary collection procedure. The procedure will be identified for the benefit of the method as the memory segment allocated together with the procedure registration and/or the temporary hinting pointer and the procedure itself.
int (*slip)(void *, void *, void *, int (*)(void *));
It is passed the temporaries allocator context (the one context pointer
inherited from the memory allocator construct), the start address of the memory
segment allocated together with the procedure registration (if one was
allocated, NULL
otherwise), the temporary hinting pointer and the
temporary collection procedure as arguments, in this order. If the second
argument is not NULL
, the third and fourth should not be used.
The method is expected to return 0
for success, non zero for failure.
Next: Consolidated Disposal Manager Construct, Previous: Memory Allocator Construct, Up: Generic Constructs [Index]