Ai-je besoin pour libérer de la strtok chaîne résultante?

Ou plutôt, comment ne strtok produire de la chaîne à laquelle il est de retour de la valeur des points? Est-il allouer de la mémoire dynamiquement? Je demande car je ne suis pas sûr si j'ai besoin de libérer le jeton dans le code suivant:

La STANDARD_INPUT variables est pour quitter la procédure dans le cas où je n'ai plus de mémoire pour l'allocation et la chaîne est testé sujet.

int ValidTotal(STANDARD_INPUT, char *str)
{
    char *cutout = NULL, *temp, delim = '#';
    int i = 0; //Checks the number of ladders in a string, 3 is the required number
    temp = (char*)calloc(strlen(str),sizeof(char));
    if(NULL == temp)
        Pexit(STANDARD_C); //Exit function, frees the memory given in STANDARD_INPUT(STANDARD_C is defined as the names given in STANDARD_INPUT)
    strcpy(temp,str);//Do not want to touch the actual string, so copying it
    cutout = strtok(temp,&delim);//Here is the lynchpin - 
    while(NULL != cutout)
    {
        if(cutout[strlen(cutout) - 1] == '_')
            cutout[strlen(cutout) - 1] = '
int ValidTotal(STANDARD_INPUT, char *str)
{
char *cutout = NULL, *temp, delim = '#';
int i = 0; //Checks the number of ladders in a string, 3 is the required number
temp = (char*)calloc(strlen(str),sizeof(char));
if(NULL == temp)
Pexit(STANDARD_C); //Exit function, frees the memory given in STANDARD_INPUT(STANDARD_C is defined as the names given in STANDARD_INPUT)
strcpy(temp,str);//Do not want to touch the actual string, so copying it
cutout = strtok(temp,&delim);//Here is the lynchpin - 
while(NULL != cutout)
{
if(cutout[strlen(cutout) - 1] == '_')
cutout[strlen(cutout) - 1] = '\0'; \\cutout the _ at the end of a token
if(Valid(cutout,i++) == INVALID) //Checks validity for substring, INVALID is -1
return INVALID;
cutout = strtok(NULL,&delim);
strcpy(cutout,cutout + 1); //cutout the _ at the beginning of a token
}
free(temp);
return VALID; //VALID is 1
}
'
; \\cutout the _ at the end of a token if(Valid(cutout,i++) == INVALID) //Checks validity for substring, INVALID is -1 return INVALID; cutout = strtok(NULL,&delim); strcpy(cutout,cutout + 1); //cutout the _ at the beginning of a token } free(temp); return VALID; //VALID is 1 }
Ne pas, ne pas besoin, car il renvoie l'adresse de la partie de la temp En termes de code à strtok. temp libéré par free(temp)

OriginalL'auteur Sunspawn | 2014-01-03