Skip to content

Commit 7b18f1f

Browse files
committed
Remove string duplication
1 parent 37d49e2 commit 7b18f1f

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/util/piped_process.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,11 @@ piped_processt::piped_processt(const std::vector<std::string> commandvec)
182182
unsigned long i = 0;
183183
while(i < commandvec.size())
184184
{
185-
args[i] = strdup(commandvec[i].c_str());
185+
args[i] = const_cast<char *>(commandvec[i].c_str());
186186
i++;
187187
}
188188
args[i] = NULL;
189189
execvp(commandvec[0].c_str(), args);
190-
// The args variable will be handled by the OS if execvp succeeds, but
191-
// if execvp fails then we should free it here (just in case the runtime
192-
// error below continues execution.)
193-
while(i > 0)
194-
{
195-
i--;
196-
free(args[i]);
197-
}
198-
free(args);
199190
// Only reachable if execvp failed
200191
std::cerr << "Launching " << commandvec[0]
201192
<< " failed with error: " << strerror(errno) << std::endl;

0 commit comments

Comments
 (0)