Skip to content

Conversation

@Di0nisP
Copy link
Owner

@Di0nisP Di0nisP commented Nov 17, 2025

No description provided.

@Di0nisP Di0nisP changed the title my first commit Денис Плотников Nov 17, 2025
@Di0nisP Di0nisP requested a review from czertyaka November 19, 2025 07:56
Copy link
Collaborator

@czertyaka czertyaka left a comment

Choose a reason for hiding this comment

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

Задание принято! Очень хорошая и подробная документация, ясный код. Исправление замечаний на ваше усмотрение.

return 0u;

stack_entry_t* const entry = &g_table.entries[hstack];
if (entry == NULL || entry->stack == NULL)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Статический анализатор подсказывает, что entry не может быть нулем (условие всегда ложно). По-моему, он прав

return 0u;
// Если копировать доступное валидное:
//const unsigned int copy_size = (node->size < size) ? node->size : size;
void* payload = (void*)(node + 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Указатель может быть константым. Хорошее правило — делать константой все, что не должно меняться. Я бы тут сделал

const void* const payload = /**/;

*
* @ref stack_t
*/
const struct node* prev;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Мое субъективное мнение: если вам в вашем коде приходится кастить константный объект к мутабельному, изначально не стоило делать его константым.

/**
* @brief Количество элементов в таблице.
*
* Определяет размер массива @ref stack_entries_table::entries .
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* Определяет размер массива @ref stack_entries_table::entries .
* Определяет размер массива @ref stack_entries_table::entries.

if (g_table.entries != NULL) {
for (unsigned int i = 0; i < g_table.size; ++i) {
if (g_table.entries[i].reserved == 0)
return (int)i;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Формально должно быть сравнение с INT_MAX


// Cвободного слота нет -> расширить таблицу минимум до (g_table.size + 1)
const unsigned int old_size = g_table.size;
if (table_ensure_capacity(old_size + 1) != 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Я бы предложил воспользоваться стратегией класса std::vector из C++ и увеличивать емкость в 2 раза.

g_table.entries[slot].stack = NULL; // Стек пуст

// Вернуть индекс слота как hstack_t
return (hstack_t)slot;
Copy link
Collaborator

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.

3 participants