incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Farid Zaripov <Far...@kyiv.vdiweb.com>
Subject RE: Environment for the test of the string functions memory overrun with example
Date Thu, 13 Jul 2006 16:24:05 GMT
   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.


Mime
View raw message