mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-03 14:20:27 +00:00
cmCPluginAPI: use strdup() instead of open coding it
This commit is contained in:
@@ -405,14 +405,8 @@ char CCONV* cmExpandVariablesInString(void* arg, const char* source,
|
|||||||
{
|
{
|
||||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||||
std::string barf = source;
|
std::string barf = source;
|
||||||
std::string result = mf->ExpandVariablesInString(
|
std::string result = mf->ExpandVariablesInString(barf, escapeQuotes, atOnly);
|
||||||
barf, (escapeQuotes ? true : false), (atOnly ? true : false));
|
return strdup(result.c_str());
|
||||||
char* res = static_cast<char*>(malloc(result.size() + 1));
|
|
||||||
if (!result.empty()) {
|
|
||||||
strcpy(res, result.c_str());
|
|
||||||
}
|
|
||||||
res[result.size()] = '\0';
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs,
|
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)
|
char* CCONV cmGetFilenameWithoutExtension(const char* name)
|
||||||
{
|
{
|
||||||
std::string sres = cmSystemTools::GetFilenameWithoutExtension(name);
|
std::string sres = cmSystemTools::GetFilenameWithoutExtension(name);
|
||||||
char* result = (char*)malloc(sres.size() + 1);
|
return strdup(sres.c_str());
|
||||||
strcpy(result, sres.c_str());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* CCONV cmGetFilenamePath(const char* name)
|
char* CCONV cmGetFilenamePath(const char* name)
|
||||||
{
|
{
|
||||||
std::string sres = cmSystemTools::GetFilenamePath(name);
|
std::string sres = cmSystemTools::GetFilenamePath(name);
|
||||||
char* result = (char*)malloc(sres.size() + 1);
|
return strdup(sres.c_str());
|
||||||
strcpy(result, sres.c_str());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* CCONV cmCapitalized(const char* name)
|
char* CCONV cmCapitalized(const char* name)
|
||||||
{
|
{
|
||||||
std::string sres = cmSystemTools::Capitalized(name);
|
std::string sres = cmSystemTools::Capitalized(name);
|
||||||
char* result = (char*)malloc(sres.size() + 1);
|
return strdup(sres.c_str());
|
||||||
strcpy(result, sres.c_str());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCONV cmCopyFileIfDifferent(const char* name1, const char* name2)
|
void CCONV cmCopyFileIfDifferent(const char* name1, const char* name2)
|
||||||
|
|||||||
Reference in New Issue
Block a user