[PPL-devel] [GIT] ppl/ppl(sparse_matrices): Tightened the implementation of the `--max-memory' option.

Roberto Bagnara bagnara at cs.unipr.it
Sat Aug 28 14:32:07 CEST 2010


Module: ppl/ppl
Branch: sparse_matrices
Commit: f75832a600dfb6af890af3fb94cb99500d7e5de4
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=f75832a600dfb6af890af3fb94cb99500d7e5de4

Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date:   Sat Aug 28 14:31:18 2010 +0200

Tightened the implementation of the `--max-memory' option.

---

 demos/ppl_lcdd/ppl_lcdd.cc  |    3 +++
 demos/ppl_lpsol/ppl_lpsol.c |    3 +++
 demos/ppl_pips/ppl_pips.cc  |    4 +++-
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/demos/ppl_lcdd/ppl_lcdd.cc b/demos/ppl_lcdd/ppl_lcdd.cc
index 54516b2..3b1f222 100644
--- a/demos/ppl_lcdd/ppl_lcdd.cc
+++ b/demos/ppl_lcdd/ppl_lcdd.cc
@@ -92,6 +92,7 @@ typedef Polyhedron* POLYHEDRON_TYPE;
 #include <vector>
 #include <set>
 #include <limits>
+#include <climits>
 #include <cassert>
 #include <cstdarg>
 #include <csignal>
@@ -415,6 +416,8 @@ process_options(int argc, char* argv[]) {
       l = strtol(optarg, &endptr, 10);
       if (*endptr || l < 0)
 	fatal("a non-negative integer must follow `-R'");
+      else if (((unsigned long) l) > ULONG_MAX/(1024*1024))
+        max_bytes_of_virtual_memory = ULONG_MAX;
       else
 	max_bytes_of_virtual_memory = l*1024*1024;
       break;
diff --git a/demos/ppl_lpsol/ppl_lpsol.c b/demos/ppl_lpsol/ppl_lpsol.c
index ec4a5d6..3828f6e 100644
--- a/demos/ppl_lpsol/ppl_lpsol.c
+++ b/demos/ppl_lpsol/ppl_lpsol.c
@@ -26,6 +26,7 @@ site: http://www.cs.unipr.it/ppl/ . */
 #include <gmp.h>
 #include <stdio.h>
 #include <assert.h>
+#include <limits.h>
 #include <time.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -337,6 +338,8 @@ process_options(int argc, char* argv[]) {
       l = strtol(optarg, &endptr, 10);
       if (*endptr || l < 0)
 	fatal("a non-negative integer must follow `-R'");
+      else if (((unsigned long) l) > ULONG_MAX/(1024*1024))
+        max_bytes_of_virtual_memory = ULONG_MAX;
       else
 	max_bytes_of_virtual_memory = l*1024*1024;
       break;
diff --git a/demos/ppl_pips/ppl_pips.cc b/demos/ppl_pips/ppl_pips.cc
index 72502ab..0fb1b8e 100644
--- a/demos/ppl_pips/ppl_pips.cc
+++ b/demos/ppl_pips/ppl_pips.cc
@@ -56,7 +56,7 @@ ppl_set_GMP_memory_allocation_functions(void) {
 #include <gmpxx.h>
 #include <vector>
 #include <set>
-#include <limits>
+#include <climits>
 #include <cassert>
 #include <cstdarg>
 #include <csignal>
@@ -669,6 +669,8 @@ process_options(int argc, char* argv[]) {
       l = strtol(optarg, &endptr, 10);
       if (*endptr || l < 0)
 	fatal("a non-negative integer must follow `-R'");
+      else if (((unsigned long) l) > ULONG_MAX/(1024*1024))
+        max_bytes_of_virtual_memory = ULONG_MAX;
       else
 	max_bytes_of_virtual_memory = l*1024*1024;
       break;




More information about the PPL-devel mailing list