Skip to content

Conversation

@TookTM
Copy link
Owner

@TookTM TookTM commented Nov 18, 2025

No description provided.

@TookTM TookTM changed the title Bip Nicolay Petrov Nov 18, 2025
@TookTM TookTM requested a review from czertyaka November 19, 2025 08:36

// ��������� ����������� ����� � ���������� ������
struct stack_list {
struct stack_list* prev; // ��������� �� ���������� ���������� � ������
Copy link
Collaborator

Choose a reason for hiding this comment

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

Комментарии в GitHub не отображаются из-за кодировки, возможно в них есть ответ на мой вопрос. Почему решили сделать двусявзный список?

return -1;
// �������� ������ ��� ����� ���������� �����
struct stack_list* new_root = (struct stack_list*)malloc(sizeof(struct stack_list));
if (new_root) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

С точки зрения читаемости проще было бы сделать early return

struct stack_list* new_root = (struct stack_list*)malloc(sizeof(struct stack_list));
if (new_root) {
// ������������� ��������� ���������� ��� ������ ���������� �����������
struct stack_list* temp;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Неинициализированный указатель. Можно было бы сразу struct stack_list* temp = &list_root;

// ������� ���������� ���������� ����� � ���������� ������
struct stack_list* temp;
temp = &list_root;
temp = temp->next;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Эти три строки можно было записать так:

struct stack_list* temp = list_root.next;

temp = temp->next;
// ���� ����� ���� � �������� ������������, �������� ��� ��������
if (hstack == temp->descriptor) {
valid_handler = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Наверное тут нужен break

stack_r->prev = new_node;

// �������� ������ � ����� �������
if (new_node->data) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Результат malloc проверяется поздно, надо бы сразу после вызова делать проверку. Причем если она на прошла, new_node надо удалять, иначе будет утечка памяти

}

// ���������, ��� ����� ������������ ������� � �� NULL
if (stack_r->size <= size && data_out != NULL) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Проверку data_out лучше делать в начале функции

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