Skip to content

Conversation

@kamendov-maxim
Copy link
Owner

No description provided.

@kamendov-maxim kamendov-maxim changed the title Comments лексем комментариев Dec 28, 2023
{
*len = 0;
size_t capacity = 1;
char *s = (char *)malloc(sizeof(char));

Choose a reason for hiding this comment

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

У Вас в параметрах функций * пишется с пробелом, при объявлении локальных переменных ­— нет, а лучше бы единообразно (правильнее * писать слитно с именем переменной, чтобы не путать читателя относительно того, кто именно указатель).

Choose a reason for hiding this comment

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

А ещё s как имя переменной — не очень

char *copy = (char *)malloc(len * sizeof(char));
if (copy != NULL)
{
strcpy(copy, string);

Choose a reason for hiding this comment

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

len должна быть на 1 больше strlen, чтобы ещё нулевой байт вместить

Comment on lines +7 to +8
char *getString(size_t * const len, FILE * file, char const endOfLine);
char *copyString(char const * const string);

Choose a reason for hiding this comment

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

Надо комментарии

#pragma once

#include <stdbool.h>
#include <string.h>

Choose a reason for hiding this comment

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

Думаю, что этот файл в хедере не нужен

{
return firstStar;
}
return start;

Choose a reason for hiding this comment

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

Не-а. //* текст */ тоже комментарий, просто первая / не является его частью


default:
return start;
break;

Choose a reason for hiding this comment

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

break не нужен, до него никогда управление не дойдёт


ErrorCode addComment(List *list, size_t start, size_t end, const char *const text)
{
char *string = malloc((start + end + 1) * sizeof(char));

Choose a reason for hiding this comment

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

start + end, не end - start?


#define FILENAME "../file.txt"

typedef enum exitCode

Choose a reason for hiding this comment

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

Suggested change
typedef enum exitCode
typedef enum ExitCode


if (len != answersSize)
{
return false;

Choose a reason for hiding this comment

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

Надо ещё удалить comments

return false;
}
}
free(comments);

Choose a reason for hiding this comment

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

Тут и выше надо удалить ещё и строки массива — массив ведь представляет собой массив указателей на строки, которые тоже выделены на куче

}
return start;
}

Choose a reason for hiding this comment

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

лишний пробел тут и ниже

{
return firstStar;
}
return start;

Choose a reason for hiding this comment

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

//*

size_t i = 0;
for (Node *node = list->head; node != NULL; node = node->next)
{
output[i] = node->value;

Choose a reason for hiding this comment

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

переименовать функцию в convertToArray и внутри удалять список
указатель на value занулять

{
Node *temp = currentNode;
currentNode = currentNode->next;
// free(temp->value);

Choose a reason for hiding this comment

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

раскомментировать

return calloc(1, sizeof(List));
}

ErrorCode addElement(List *list, char *const value)

Choose a reason for hiding this comment

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

* const в .h тоже


if (len != answersSize)
{
return false;

Choose a reason for hiding this comment

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

память чистить в любом случае

Comment on lines +21 to +25
free(comments);
return false;
}
}
free(comments);

Choose a reason for hiding this comment

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

строки тоже удалять

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.

4 participants