I made the first version of the rw_alloc() / rw_free().
Memory leak checking is not implemented.
The files are attached.
------------------------------------------------------------
tests/include/rw_alloc.h
tests/src/alloc.cpp
enum {
RW_PROT_NONE = 0,
RW_PROT_READ = 1 << 0,
RW_PROT_WRITE = 1 << 1,
RW_PROT_RDWR = RW_PROT_READ | RW_PROT_WRITE,
RW_PROT_EXEC = 1 << 2,
RW_PROT_BELOW = 1 << 3
};
// if flags == -1 memory will be allocated by malloc();
// if flags != -1 memory will be allocated by system call and
// additional guard page with PAGE_NOACCESS protection will be allocated
// if RW_PROT_BELOW & flags != 0 then guard page will be located right
// before the user data, otherwise - right after the user data
// if RWSTD_ALLOC_FLAGS environment variable is defined and != 0
// then rw_alloc will use value of RWSTD_ALLOC_FLAGS instead of flags
variable
_TEST_EXPORT void*
rw_alloc(size_t, int /*flags*/ = -1);
// free the memory block, allocated by rw_alloc()
_TEST_EXPORT void
rw_free(void*);
Farid.
|