From 8189bf8d9772d8d80ee2952c5579b4260332083d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 13 Nov 2013 11:29:17 +0100 Subject: [PATCH] Switch to std::string in order to avoid a new/delete mismatch error in test code --- .../include/test_types.h | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) mode change 100644 => 100755 Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h diff --git a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h old mode 100644 new mode 100755 index 573f00e38b5..6a454f72042 --- a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h +++ b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/include/test_types.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "IO/Null_output_stream.h" #include "IO/io_aux.h" @@ -17,24 +18,18 @@ //======================================================================== template -char* get_fname(const NT&, const char* ifname) { - char* fname = new char[50]; - std::strcpy(fname, "data/"); - std::strcat(fname, ifname); - std::strcat(fname, ".cin"); - return fname; +std::string get_fname(const NT&, std::string ifname) +{ + return std::string("data/") + ifname + ".cin"; } #ifdef CGAL_USE_GMP #include template<> -char* get_fname(const CGAL::Gmpq&, const char* ifname) { - char* fname = new char[50]; - std::strcpy(fname, "data/"); - std::strcat(fname, ifname); - std::strcat(fname, ".Gmpq.cin"); - return fname; +std::string get_fname(const CGAL::Gmpq&, std::string ifname) +{ + return std::string("data/") + ifname + ".Gmpq.cin"; } #endif @@ -79,7 +74,7 @@ template bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname, bool test_remove) { - char* ifname_full = get_fname(typename SDG2::Geom_traits::FT(), ifname); + std::string ifname_full = get_fname(typename SDG2::Geom_traits::FT(), ifname); typedef SDG SDG2; @@ -366,7 +361,7 @@ bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname, { sdg.clear(); - std::ifstream ifs( ifname_full ); + std::ifstream ifs( ifname_full.c_str() ); assert( ifs ); Site_2 t; while ( ifs >> t ) { @@ -564,7 +559,6 @@ bool test_sdg(InputStream&, const SDG&, const char* ifname, const char* ofname, start_testing("validity check and clear methods"); end_testing("validity check and clear method"); - delete ifname_full; return true; }