Rain Software
C++ array boundary check

    Main
    Downlaod
    Contact
    About

C++ array boundary check NEW
[1] Description
[2] Usage
[3] Contact


[1] Features
In C++ the most common problem is the memory management, in the site I found many articles talking about the memory leak detection, but there is another problem is array boundary, there is no check when you write beyond allocated array size in most cases you can't detect it and cause many random runtime errors.

[2] Usage
How we detect it?
In my code we do override the new operator, and when new memory is requested we do allocate it using VirtualAlloc and allocate the requested size and additional page after that we do change the attribute for the very last page as PAGE_NOACCESS and adjust the return pointer to align its end to the start of the non-access page, whenever you make an attempt to write on this part or read you get Access violation. The code is to help you to check on your dynamic array so remember to use it in debug mode.

Attached code contains three project.
MemChk: static library contains the code for new override.
MemChkTest: a demonstration project showing the idea when the for loop attempts to access invalid index ACCESS_VIOLATION exception occurs.
NoMemChk: shows array normal allocation and you try to write on invalid memory nothing happens and the application continue.

Using in your code
Include the header file in cpp files and link your project with "MemChk.lib".

[3] Contact
See contact Page

Download C++ array boundary check

Your Ad Here




This website is hosted for free by Freewebs.com - free website. Get your own Free Website now!