|
cds
1.3.0
|
Option setter for bounds checking. More...
#include <cds/memory/michael/options.h>
Option setter for bounds checking.
This option defines a strategy to check upper memory boundary of allocated blocks. Type defines a class for bound checking with following interface:
Before allocating a memory block of size N, the heap adds the trailer_size to N and really it allocates N + trailer_size bytes. Then, the heap calls make_trailer function of bound checker with arguments:
pStartArea - start of allocated blockpEndBlock - the first byte after really allocated block;nAllocSize - requested size in bytes (i.e. N) So, make_trailer function can place some predefined value called bound mark of any type, for example, int64, on address pStartArea + nAllocSize, and store real allocated block size N to pEndBlock - sizeof(size_t). In this example, trailer_size constant is equal sizeof(int64) + sizeof(size_t).Before the memory block previously allocated is deallocating, the check_bounds function is called. The function has similar signature:
pStartArea - start of allocated block (like make_trailer fist argument)pEndBlock - the first byte after allocated block (like make_trailer second argument)nBlockSize - real allocated block size, not equal to nAllocSize argument of make_trailer The function can:
The library provides the following predefined bound checkers, i.e they are possible values of Type template argument: