Skip to content

Conversation

@kamendov-maxim
Copy link
Owner

No description provided.

{
return MEMORY_ERROR;
}
char *text = readFile(FILE_NAME);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверить на NULL

}

return str;
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переноса нет

Comment on lines 19 to 22
if (str == NULL)
{
exit(MEMORY_ERROR);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот такие приколы лучше не делать в функциях, которые могут вызываться в произвольном участке программы, когда мы ещё не сохранили данные и не почистили память в вызывающем коде

Comment on lines 12 to 15
if (file == NULL)
{
exit(FILE_ERROR);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут аналогично - просто вернуть NULL

Comment on lines 26 to 37
else
{
if (len != 0)
{
len = lps[len - 1];
}
else
{
lps[i] = 0;
++i;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else if + else

static size_t *createLPSArray(char const *const pattern, const size_t pLength)
{
size_t len = 0;
size_t *lps = (size_t *)malloc(pLength * sizeof(size_t));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверить на NULL

Comment on lines 25 to 31
if (text == NULL)
{
free(pattern);
fclose(testFile);
return false;
}
fclose(testFile);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

один раз закрыть файл перед if

return false;
}

FILE *answerFile = fopen(answerFileName, "r");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверить на NULL


FILE *answerFile = fopen(answerFileName, "r");
size_t answer = 0;
int scanfCheck = fscanf(answerFile, "%lu", &answer);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%l - на случай, если ответ -1

}
}
free(lps);
return -1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t - unsigned long -> переделать size_t на long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants