From 8de86660464dad066ae9e5a4143f6c26e5db4883 Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 8 Aug 2016 16:36:01 -0500 Subject: [PATCH] MCOL-5 fill the vector before taking the addresses of the strings. --- dbcon/mysql/ha_calpont_impl.cpp | 5 +++-- writeengine/server/we_dataloader.cpp | 5 +++-- writeengine/splitter/we_splitterapp.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index c339f9216..c66cf944c 100755 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -3456,11 +3456,12 @@ void ha_calpont_impl_start_bulk_insert(ha_rows rows, TABLE* table) std::istringstream ss(aCmdLine); std::string arg; std::vector v2(20, ""); + unsigned int i = 0; while (ss >> arg) { - v2.push_back(arg); + v2[i++] = arg; } - for (unsigned int i = 0; i < v2.size(); ++i) + for (i = 0; i < v2.size(); ++i) { Cmds.push_back(const_cast(v2[i].c_str())); } diff --git a/writeengine/server/we_dataloader.cpp b/writeengine/server/we_dataloader.cpp index 0742053dd..79e7aef84 100644 --- a/writeengine/server/we_dataloader.cpp +++ b/writeengine/server/we_dataloader.cpp @@ -248,11 +248,12 @@ bool WEDataLoader::setupCpimport() // fork the cpimport std::istringstream ss(aCmdLine); std::string arg; std::vector v2(20, ""); + unsigned int i = 0; while (ss >> arg) { - v2.push_back(arg); + v2[i++] = arg; } - for (unsigned int i = 0; i < v2.size(); ++i) + for (i = 0; i < v2.size(); ++i) { Cmds.push_back(const_cast(v2[i].c_str())); } diff --git a/writeengine/splitter/we_splitterapp.cpp b/writeengine/splitter/we_splitterapp.cpp index dc6c84b70..afaeb4edb 100644 --- a/writeengine/splitter/we_splitterapp.cpp +++ b/writeengine/splitter/we_splitterapp.cpp @@ -453,16 +453,16 @@ void WESplitterApp::invokeCpimport() std::istringstream ss(aCmdLineStr); std::string arg; std::vector v2(20, ""); + unsigned int i = 0; while(ss >> arg) { //we need something that works on Windows as well as linux - v2.push_back(arg); + v2[i++] = arg; } - for (unsigned int i = 0; i < v2.size(); ++i) + for (i = 0; i < v2.size(); ++i) { //we're going to exec() below, so don't worry about freeing - ptr = strdup(v2.back().c_str()); - Cmds.push_back(ptr); + Cmds.push_back(const_cast(v2[i].c_str())); } Cmds.push_back(0); //null terminate