Refactoring: strdup also exists in MSVS
This commit is contained in:
parent
1f141e4dc0
commit
1f68dfa57e
|
@ -32,9 +32,6 @@
|
|||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define _strdup(str) strdup(str)
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -49,11 +49,7 @@ void TOKEN::setstr( const char s[] )
|
|||
{
|
||||
_str = s;
|
||||
std::free(_cstr);
|
||||
#ifndef _MSC_VER
|
||||
_cstr = strdup(s);
|
||||
#else
|
||||
_cstr = _strdup(s);
|
||||
#endif
|
||||
_isName = bool(_str[0]=='_' || isalpha(_str[0]));
|
||||
_isNumber = bool(isdigit(_str[0]) != 0);
|
||||
if( _str == "true" || _str == "false" )
|
||||
|
|
11
tokenize.cpp
11
tokenize.cpp
|
@ -42,11 +42,6 @@
|
|||
#include <mem.h>
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define _strdup(str) strdup(str)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
@ -117,7 +112,7 @@ void Tokenizer::Define(const char Name[], const char Value[])
|
|||
if (!dec && !hex)
|
||||
return;
|
||||
|
||||
char *strValue = _strdup(Value);
|
||||
char *strValue = strdup(Value);
|
||||
|
||||
if (!dec && hex)
|
||||
{
|
||||
|
@ -128,12 +123,12 @@ void Tokenizer::Define(const char Name[], const char Value[])
|
|||
std::ostringstream ostr;
|
||||
ostr << value;
|
||||
free(strValue);
|
||||
strValue = _strdup(ostr.str().c_str());
|
||||
strValue = strdup(ostr.str().c_str());
|
||||
}
|
||||
|
||||
DefineSymbol *NewSym = new DefineSymbol;
|
||||
memset(NewSym, 0, sizeof(DefineSymbol));
|
||||
NewSym->name = _strdup(Name);
|
||||
NewSym->name = strdup(Name);
|
||||
NewSym->value = strValue;
|
||||
NewSym->next = _dsymlist;
|
||||
_dsymlist = NewSym;
|
||||
|
|
Loading…
Reference in New Issue