[PPL-devel] [GIT] ppl/ppl(master): Fixed a few memory allocation problems in ppl_pips.
Enea Zaffanella
zaffanella at cs.unipr.it
Thu Mar 18 07:44:03 CET 2010
Module: ppl/ppl
Branch: master
Commit: 2df786e330fbe20f7c268860bd791cc627d4c22a
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=2df786e330fbe20f7c268860bd791cc627d4c22a
Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date: Wed Mar 17 17:14:35 2010 +0100
Fixed a few memory allocation problems in ppl_pips.
Enabled the used of valgrind when running ppl_pips tests.
Corrected the expected result for test fimmel.pip (unsatisfiable problem).
---
demos/ppl_pips/Makefile.am | 21 +++++++++++++++++----
demos/ppl_pips/expected_mpz_a | 2 +-
demos/ppl_pips/ppl_pips.cc | 11 ++++++-----
3 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/demos/ppl_pips/Makefile.am b/demos/ppl_pips/Makefile.am
index 6d7f5d8..cfb9d17 100644
--- a/demos/ppl_pips/Makefile.am
+++ b/demos/ppl_pips/Makefile.am
@@ -22,6 +22,19 @@
SUBDIRS = examples
+if VALGRIND_TESTS_ENABLED
+
+CHECKER = \
+$(VALGRIND) --tool=memcheck -q --trace-children=yes --leak-check=yes \
+--num-callers=100 --leak-resolution=high \
+--suppressions=$(top_srcdir)/tests/valgrind_suppressions
+
+else !VALGRIND_TESTS_ENABLED
+
+CHECKER =
+
+endif !VALGRIND_TESTS_ENABLED
+
AM_CPPFLAGS = \
-I$(top_builddir) \
-I$(top_builddir)/src \
@@ -85,8 +98,8 @@ check-local: ppl_pips$(EXEEXT)
$(FGREP) $$file tough_examples >/dev/null 2>&1 && continue; \
echo $(ECHO_N) $$file " $(ECHO_C)" >>obtained; \
echo ppl_pips$(EXEEXT) -p $$path; \
- ./ppl_pips$(EXEEXT) -p $$path | tr -d '\015' | $(TEXT_MD5SUM) \
- >>obtained; \
+ $(CHECKER) ./ppl_pips$(EXEEXT) -p $$path \
+ | tr -d '\015' | $(TEXT_MD5SUM) >>obtained; \
done
for path in $(srcdir)/examples/*.pip; \
do \
@@ -94,8 +107,8 @@ check-local: ppl_pips$(EXEEXT)
$(FGREP) $$file tough_examples >/dev/null 2>&1 && continue; \
echo $(ECHO_N) $$file " $(ECHO_C)" >>obtained; \
echo ppl_pips$(EXEEXT) -P $$path; \
- ./ppl_pips$(EXEEXT) -P $$path | tr -d '\015' | $(TEXT_MD5SUM) \
- >>obtained; \
+ $(CHECKER) ./ppl_pips$(EXEEXT) -P $$path \
+ | tr -d '\015' | $(TEXT_MD5SUM) >>obtained; \
done
diff obtained $(srcdir)/$(EXPECTED)
diff --git a/demos/ppl_pips/expected_mpz_a b/demos/ppl_pips/expected_mpz_a
index 70658db..96b9a87 100644
--- a/demos/ppl_pips/expected_mpz_a
+++ b/demos/ppl_pips/expected_mpz_a
@@ -14,7 +14,7 @@ brisebarre.pip 3051dbe7ea7bf04e8890ddd41013a9dc -
cg1.pip 2571d40371dd1f1661348b08945e8a98 -
esced.pip 7f4b69aed82cc0f498e7931ac1dbf92f -
ex2.pip 89eb267478eb8675de9602be9bb92f9e -
-fimmel.pip d41d8cd98f00b204e9800998ecf8427e -
+fimmel.pip 2dd9b24df50572c15981dd3faf8c74a4 -
max.pip e29c651c587cc64ab6a7a8cecd488a0b -
sor1d.pip 8722a9d4eedd28b98c12987c9116564e -
square.pip 65a57d1e7ccb8196f81fa6e701164b69 -
diff --git a/demos/ppl_pips/ppl_pips.cc b/demos/ppl_pips/ppl_pips.cc
index 223a458..1c35ab6 100644
--- a/demos/ppl_pips/ppl_pips.cc
+++ b/demos/ppl_pips/ppl_pips.cc
@@ -68,6 +68,7 @@ ppl_set_GMP_memory_allocation_functions(void) {
#include <fstream>
#include <sstream>
#include <stdexcept>
+#include <memory>
#ifdef PPL_HAVE_GETOPT_H
#include <getopt.h>
@@ -770,11 +771,11 @@ main(int argc, char* argv[]) try {
// POLYHEDRON_TYPE ph;
// Representation rep = read_polyhedron(input(), ph);
- PIP_Parser* parser;
+ std::auto_ptr<PIP_Parser> parser;
if (piplib_format)
- parser = new PIP_PipLib_Parser();
+ parser.reset(new PIP_PipLib_Parser);
else
- parser = new PIP_PolyLib_Parser();
+ parser.reset(new PIP_PolyLib_Parser);
if (!parser->read(*input_stream_p))
return 1;
@@ -789,11 +790,11 @@ main(int argc, char* argv[]) try {
parser->output_solution_tree(*output_stream_p);
}
else {
+ std::auto_ptr<PPL::PIP_Problem> pipp;
// Perform a time benchmark loop executing the resolution several times.
for (int i = 0; i < loop_iterations; ++i) {
- PPL::PIP_Problem* pipp = new PPL::PIP_Problem(pip);
+ pipp.reset(new PPL::PIP_Problem(pip));
pipp->solve();
- delete pipp;
}
}
More information about the PPL-devel
mailing list