CodePudding user response:
STR is only a memory, multiple calls will be chaosCodePudding user response:
Is it possible is the length of strSource may outweigh the MAX_STR_LEN, leading to an arrayCodePudding user response:
Possible, so you have a code problem
Char * _strdup (const char * strSource)
{
If (strSource==NULL)
return NULL;
Int len=strlen (strSource);
Char * result=(char *) malloc (sizeof (char) * (len + 1));
Strcpy (result, strSource);
Result [len]='\ 0';
return result;
}
CodePudding user response:
1) suspected of crossing the line, this can't avoid an array,2) multithreaded operations, this function is not atomic operations, multi-threaded operation data content may be chaotic;