# PlugScape : C++ memory checks and benchmarking

## Overview

A small library for C++/GNU/Linux to find bugs and memory leaks and benchmark your application. Available under the GPLv2 or any later version.

Bugs are found using contract programming and asserts, memory leaks are found with an overload of the new and delete operators.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details

## Installation Instructions

• install plugscape : $sudo dpkg -i plugscape_0.8-1_i386.deb ### Installation from source • Install CMake. • Install the Boost Libraries and more specifically Boost Date-Time if it is distributed in a different package for your operating system. • Download and extract the contents of the plugscape source archive. • Inside the newly created directory configure the package :$ cmake . .
• build the project : $make • (Optional) install it with administrator privileges :$ make install or \$ sudo make install . The location of the installed files is recorded in the file “install-manifest.txt” for later removal.

## How to use contract programming ?

Then use the following macros in your code : ”INVARIANT, REQUIRE, ENSURE, ASSERT, EXPECT”.

Compile your project with the definition ”PLUGSCAPE_CONTRACT”. You can disable it later for a final release.

## How to find memory leaks ?

Instead of allocating memory with ”new”, use ”NEW”. Instead of unallocating memory with ”delete”, use ”DELETE”.

If you have already written your code and do not want to change any of it, you can add the following definition:

You will have to make sure that this macro is not defined before any standard header. defining the macro ”new” will not work with code such as ”operator new”. ”new” can only be used for memory allocation.

## How to benchmark your application ?

Place function calls you want to test inside a BENCHMARK macro call.

Compile your project with the definition PLUGSCAPE_BENCHMARK. You can disable it later for a final release.