-
Notifications
You must be signed in to change notification settings - Fork 0
Nicolay Petrov #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This reverts commit d28ad94.
|
|
||
| // ��������� ����������� ����� � ���������� ������ | ||
| struct stack_list { | ||
| struct stack_list* prev; // ��������� �� ���������� ���������� � ������ |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Проверку data_out лучше делать в начале функции
No description provided.