指向泄漏内存的函数的链接。
bool check(const char* word)
{
uint32_t len = strlen(word);
char currentWord[len+1];
for(int k = 0; k <= len; k++)
{
currentWord[k] = tolower((char)word[k]);
}
bool wordPresent = false;
uint32_t indexSize = (dict.wordCount / ITEMSPERBUCKET);
uint32_t index = (hashFunction(currentWord)%(indexSize-1));
dictNode *temp = malloc(sizeof(dictNode));
temp = chainedHashTable[index];
do
{
if (strncmp(temp->word, currentWord, temp->len) == 0)
{
wordPresent = true;
temp = NULL;
}
else
{
temp = temp->next;
}
}
while (temp != NULL);
free(temp);
return wordPresent;
}
任何帮助将不胜感激。