summaryrefslogtreecommitdiffstats
path: root/Source/cmCPluginAPI.cxx
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2017-09-23 12:39:20 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2017-09-23 13:30:44 (GMT)
commit6e2b18535bf3ffd9400d73462fd2a0f1a609664e (patch)
tree76aaef8368a95fb5d13e95646e26364c125e333a /Source/cmCPluginAPI.cxx
parent7a7e96e2786d78d19192a010991eda64291aa23a (diff)
downloadCMake-6e2b18535bf3ffd9400d73462fd2a0f1a609664e.zip
CMake-6e2b18535bf3ffd9400d73462fd2a0f1a609664e.tar.gz
CMake-6e2b18535bf3ffd9400d73462fd2a0f1a609664e.tar.bz2
cmCPluginAPI: use strdup() instead of open coding it
Diffstat (limited to 'Source/cmCPluginAPI.cxx')
-rw-r--r--Source/cmCPluginAPI.cxx22
1 files changed, 5 insertions, 17 deletions
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index e259f4d..8b6fd97 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -405,14 +405,8 @@ char CCONV* cmExpandVariablesInString(void* arg, const char* source,
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
std::string barf = source;
- std::string result = mf->ExpandVariablesInString(
- barf, (escapeQuotes ? true : false), (atOnly ? true : false));
- char* res = static_cast<char*>(malloc(result.size() + 1));
- if (!result.empty()) {
- strcpy(res, result.c_str());
- }
- res[result.size()] = '\0';
- return res;
+ std::string result = mf->ExpandVariablesInString(barf, escapeQuotes, atOnly);
+ return strdup(result.c_str());
}
int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs,
@@ -762,25 +756,19 @@ void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir,
char* CCONV cmGetFilenameWithoutExtension(const char* name)
{
std::string sres = cmSystemTools::GetFilenameWithoutExtension(name);
- char* result = (char*)malloc(sres.size() + 1);
- strcpy(result, sres.c_str());
- return result;
+ return strdup(sres.c_str());
}
char* CCONV cmGetFilenamePath(const char* name)
{
std::string sres = cmSystemTools::GetFilenamePath(name);
- char* result = (char*)malloc(sres.size() + 1);
- strcpy(result, sres.c_str());
- return result;
+ return strdup(sres.c_str());
}
char* CCONV cmCapitalized(const char* name)
{
std::string sres = cmSystemTools::Capitalized(name);
- char* result = (char*)malloc(sres.size() + 1);
- strcpy(result, sres.c_str());
- return result;
+ return strdup(sres.c_str());
}
void CCONV cmCopyFileIfDifferent(const char* name1, const char* name2)